Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Initial work for LocaleMemberDAOITCase.
Browse files Browse the repository at this point in the history
This is an in-container test.
  • Loading branch information
Carlos Munoz committed May 6, 2013
1 parent fbc190e commit 91fd41d
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 163 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -357,6 +357,12 @@
<!-- TODO Overwritten from arquillian BOM 1.0.3.Final to use the MavenImporter -->
</dependency>

<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<version>1.0.3.Final</version>
</dependency>

<!-- Arquillian -->
<dependency>
<groupId>org.jboss.arquillian</groupId>
Expand Down
26 changes: 13 additions & 13 deletions zanata-war/src/test/java/org/zanata/ZanataDbunitJpaTest.java
Expand Up @@ -20,11 +20,11 @@
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
import org.dbunit.operation.DatabaseOperation;
import org.hibernate.internal.SessionImpl;
//import org.testng.annotations.AfterMethod;
//import org.testng.annotations.BeforeClass;
//import org.testng.annotations.BeforeMethod;
//import org.testng.annotations.Optional;
//import org.testng.annotations.Parameters;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;

public abstract class ZanataDbunitJpaTest extends ZanataJpaTest
{
Expand All @@ -36,9 +36,9 @@ public abstract class ZanataDbunitJpaTest extends ZanataJpaTest

private boolean prepared = false;

//@BeforeClass
//@Parameters("binaryDir")
public void setBinaryDir(/*@Optional*/ String binaryDir)
@BeforeClass
@Parameters("binaryDir")
public void setBinaryDir(@Optional String binaryDir)
{
if (binaryDir == null)
return;
Expand All @@ -50,9 +50,9 @@ protected String getBinaryDir()
return binaryDir;
}

//@BeforeClass
//@Parameters("replaceNull")
public void setReplaceNull(/*@Optional*/ Boolean replaceNull)
@BeforeClass
@Parameters("replaceNull")
public void setReplaceNull(@Optional Boolean replaceNull)
{
if (replaceNull == null)
return;
Expand All @@ -64,7 +64,7 @@ protected Boolean isReplaceNull()
return replaceNull;
}

//@BeforeMethod
@BeforeMethod
public void prepareDataBeforeTest()
{
// This is not pretty but we unfortunately can not have dependencies
Expand All @@ -91,7 +91,7 @@ public void prepareDataBeforeTest()
clearCache();
}

//@AfterMethod
@AfterMethod
public void cleanDataAfterTest()
{
executeOperations(afterTestOperations);
Expand Down
Expand Up @@ -61,6 +61,9 @@ public static Archive<?> createDeployment()
// This doesn't work either...
//archive.addAsLibraries(Maven.resolver().loadPomFromFile("pom.xml").resolve("de.novanic.gwteventservice:eventservice").withoutTransitivity().asFile());

// We Don't need java melody
archive.delete("/WEB-INF/lib/javamelody-core-1.41.0.jar");

// Local packages
archive.addPackages(true, new Filter<ArchivePath>()
{
Expand Down Expand Up @@ -88,9 +91,6 @@ public boolean include(ArchivePath object)
"classes/zanata.properties");
archive.addAsWebInfResource("arquillian/test-web.xml", "web.xml");

// Liquibase changelogs
addAllAsResources(archive, new File("src/main/resources/db"));

addRemoteHelpers(archive);

// Export (to actually see what is being deployed)
Expand Down
70 changes: 70 additions & 0 deletions zanata-war/src/test/java/org/zanata/dao/LocaleMemberDAOITCase.java
@@ -0,0 +1,70 @@
package org.zanata.dao;

import javax.persistence.EntityManager;

import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.NotLoggedInException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.zanata.model.HAccount;
import org.zanata.model.HLocale;
import org.zanata.model.HLocaleMember;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.notNullValue;

/**
* TODO This test is only marked as a RestTest because it is an Arquillian based test. We need to better separate the
* hierarchy.
*/
@RunWith(Arquillian.class)
public class LocaleMemberDAOITCase
{

//@In
private LocaleMemberDAO localeMemberDAO;

//@In
private EntityManager em;

// @Override
protected void prepareDBUnitOperations()
{
// addBeforeTestOperation(new DataSetOperation("org/zanata/test/model/AccountData.dbunit.xml", DatabaseOperation.CLEAN_INSERT));
// addBeforeTestOperation(new DataSetOperation("org/zanata/test/model/LocalesData.dbunit.xml", DatabaseOperation.CLEAN_INSERT));
// addBeforeTestOperation(new DataSetOperation("org/zanata/test/model/ProjectsData.dbunit.xml", DatabaseOperation.CLEAN_INSERT));
}

@Test(expected = NotLoggedInException.class)
public void failSaveWhenNotLoggedIn() throws Exception
{
HLocale locale = em.find(HLocale.class, new Long(1));
HAccount account = em.find(HAccount.class, new Long(1));

assertThat(locale, notNullValue());
assertThat(account, notNullValue());

HLocaleMember newMember = new HLocaleMember(account.getPerson(), locale, true);
// Should fail as there is no user logged in
localeMemberDAO.makePersistent(newMember);
}

@Test
public void testSave() throws Exception
{
Identity identity = Identity.instance();
identity.getCredentials().setUsername("admin");
identity.getCredentials().setPassword("admin");
identity.login();

HLocale locale = em.find(HLocale.class, new Long(1));
HAccount account = em.find(HAccount.class, new Long(1));

assertThat(locale, notNullValue());
assertThat(account, notNullValue());

HLocaleMember newMember = new HLocaleMember(account.getPerson(), locale, true);
localeMemberDAO.makePersistent(newMember);
}
}
96 changes: 0 additions & 96 deletions zanata-war/src/test/java/org/zanata/dao/LocaleMemberDAOTest.java

This file was deleted.

52 changes: 1 addition & 51 deletions zanata-war/src/test/resources/AllIntegrationTests.tng.xml
Expand Up @@ -27,58 +27,8 @@
<test name="Seam Tests">
<classes>
<class name="org.zanata.server.rpc.ActivateWorkspaceActionSeamTest"/>
<class name="org.zanata.dao.LocaleMemberDAOTest"/>
<class name="org.zanata.dao.LocaleMemberDAOITCasese"/>
</classes>
</test>
-->
<test name="Raw Rest Tests">
<classes>
<class name="org.zanata.rest.service.raw.AccountRawRestITCase"/>
<class name="org.zanata.rest.service.raw.GlossaryRawRestITCase"/>
<class name="org.zanata.rest.service.raw.ProjectIterationRawRestITCase"/>
<class name="org.zanata.rest.service.raw.ProjectRawRestITCase"/>
<class name="org.zanata.rest.service.raw.FileRawRestITCase"/>
<class name="org.zanata.rest.service.raw.VersionRawRestITCase"/>
<class name="org.zanata.rest.service.raw.StatisticsRawRestITCase"/>
</classes>
</test>
<test name="Backwards Compatibility Tests">
<classes>
<!-- Zanata 1.3 Compatibility Tests -->
<class name="org.zanata.rest.compat.v1_3.ProjectCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.ProjectRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.AccountCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.AccountRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.VersionCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.VersionRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.TranslationsCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.TranslationsRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.ProjectIterationCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_3.ProjectIterationRawCompatibilityITCase"/>

<!-- Zanata 1.4.4 Compatibility Tests -->
<class name="org.zanata.rest.compat.v1_4_4.ProjectCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.ProjectRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.AccountCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.AccountRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.VersionCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.VersionRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.TranslationsCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.TranslationsRawCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.ProjectIterationCompatibilityITCase"/>
<class name="org.zanata.rest.compat.v1_4_4.ProjectIterationRawCompatibilityITCase"/>

<!-- Zanata 1.5.0 Compatibility Tests -->
<class name="org.zanata.rest.compat.v1_5_0.ProjectCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.ProjectRawCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.AccountCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.AccountRawCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.VersionCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.VersionRawCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.TranslationsCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.TranslationsRawCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.ProjectIterationCompatibilityTest"/>
<class name="org.zanata.rest.compat.v1_5_0.ProjectIterationRawCompatibilityTest"/>
</classes>
</test>
</suite>

0 comments on commit 91fd41d

Please sign in to comment.