[jboss-user] [JBoss Seam] - Re: Uni testing and datasource problem

jagin do-not-reply at jboss.com
Sun Jan 6 13:15:38 EST 2008


Please help me with the problem !! I've been strugling with this for two days (all weekend) and have no idea whats wrong. I'm new to JBoss Seam but not new to java web development but I have no idea what's wrong. It drives me crazy!

Can anybody try to generate any simple application with seam-gen and put to src/test test MyTest.java like this:


  | import javax.persistence.EntityManager;
  | import javax.persistence.EntityManagerFactory;
  | import javax.persistence.Persistence;
  | 
  | import org.jboss.seam.mock.SeamTest;
  | import org.testng.annotations.AfterClass;
  | import org.testng.annotations.BeforeClass;
  | import org.testng.annotations.Test;
  | 
  | public class MyTest {
  | 	
  | 	private EntityManagerFactory emf;
  | 	
  | 	public EntityManagerFactory getEntityManagerFactory() {
  | 		return emf;
  | 	}
  | 	
  | 	@BeforeClass
  | 	public void init() {
  | 		emf = Persistence.createEntityManagerFactory("project_name");
  | 	}
  | 	
  | 	@AfterClass
  | 	public void destroy() {
  | 		emf.close();
  | 	}
  | 
  | 	@Test
  | 	public void testFindByUsername() {
  | 		EntityManager em = emf.createEntityManager();
  | 		em.getTransaction().begin();
  | 		
  | 		//...		
  | 		
  | 		em.getTransaction().rollback();
  | 		em.close();
  | 	}
  | }
  | 

as a project_name put your name of the project.

and MyTest.xml like this:


  | <!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
  | 
  | <suite name="My Test" verbose="2" parallel="false">
  | 
  |    <test name="My Test">
  |      <classes>
  |        <class name="MyTest"/>
  |      </classes>
  |    </test>
  | 	
  | </suite>
  | 

next try to ant test and tell me if the test goes with no error?

For me it looks that the persistant.xml file is read before any initialization by Jboss Embedded. I check that application.xml, components.xml, ejb-jar.xml, jboss-app.xml are not read.

Please help me. I'm stucked.

Regards

Jarek


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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4117386



More information about the jboss-user mailing list