OK, I resolved this mystery.

The unit test should look like this:


  | public class MyTest extends SeamTest {
  |     
  |     private EntityManagerFactory emf;
  | 
  |     @Test
  |     public void testFindByUsername() {
  |             emf = Persistence.createEntityManagerFactory("ezapp");
  |     
  |             EntityManager em = emf.createEntityManager();
  |             em.getTransaction().begin();
  |             
  |             //...           
  |             
  |             em.getTransaction().rollback();
  |             em.close();
  |             
  |             emf.close();
  |     }
  | 
  | }
  | 

The problem was with


  |     @BeforeClass
  |     public void init() {
  |             emf = Persistence.createEntityManagerFactory("project_name");
  |     }
  | 

It seems that createEntityManagerFactory is called before JBoss Embedded is 
initialized. Is it bug? In the reference book there is an example of unit test 
with BeforeClass.

Regards

Jarek

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4117390#4117390

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4117390
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to