This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work for LocaleMemberDAOITCase.
This is an in-container test.
- Loading branch information
Carlos Munoz
committed
May 6, 2013
1 parent
fbc190e
commit 91fd41d
Showing
6 changed files
with
93 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
zanata-war/src/test/java/org/zanata/dao/LocaleMemberDAOITCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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
96
zanata-war/src/test/java/org/zanata/dao/LocaleMemberDAOTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters