This content has been marked as final.
Show 2 replies
-
1. Re: Jnit with EntityManager
obfuscator Nov 8, 2008 4:40 PM (in response to sujeet)Hi! Check the documentation on unit testing. You need to write tests as ComponentTests in order to be able to do injections.
-
2. Re: Jnit with EntityManager
sujeet Nov 10, 2008 7:19 AM (in response to sujeet)Hi Alexander,
Thanks for the response.
I tried using Component Test also.Code snippets given below:
public class UserRoleTest1 extends SeamTest{
private EntityManagerFactory emf;
public EntityManagerFactory getEntityManagerFactory()
{
return emf;
}
@BeforeClass
public void init() throws Exception
{
super.init();
emf = Persistence.createEntityManagerFactory("provisioning");
}
@AfterClass
public void destroy()
{
emf.close();
}
@Test
public void testUserRole() throws Exception {
new ComponentTest(){
@Override
protected void testComponents() throws Exception {
UserRole userRole = new UserRole();
userRole.setIdUserRole(3);
userRole.setRole("minoadmin");
userRole.setRoleDescription("admin");
}
}.run();
}
}
But again the same result , test got compiled but then there was no output nor any entry to the database.
Thanks,
Sujeet