Integration test, Error while extending SeamTest
mach31 Apr 25, 2008 4:27 PMHello i would like to make Integrations tests for my Seam Statefull Bean and i have error that i can't solve, despite my research.
I have a Seam EJB, wich contains a POJO, wich contains my EntityBean.
@Stateful @Scope(ScopeType.CONVERSATION) @Name("ejbSeam") public class EJBSeam implements EJBSeamLocale { private static final Logger aLogger = Logger.getLogger(EJBSeam.class); @PersistenceContext(type = PersistenceContextType.EXTENDED, unitName = "MyUnitName") private EntityManager em; @In(required = false) @Out(required = false) private APojo myPojoWichContainsEJBEntity; @EJB private AnInterfaceLocal MyEJBActions; private Boolean actionPossible; private String errorMessage; ... }
If I code an Integration Test wihtout extending SeamTest and without JSF actions, it works.
" @Test public class TestCFA { private EntityManagerFactory emf; private EJBActionClass anEJB; private EntityManager em; @BeforeTest public void init() { emf = Persistence.createEntityManagerFactory("formCoTestUnit"); } private void initEJB() { em = emf.createEntityManager(); EJBSeam myEjbSeam= new EJBSeam(); EJBActionClass ejbAction = new EJBActionClass(); myEjbSeam.setEm(em); myEjbSeam.setEJBActionClass(ejbAction); } public void testPrepareAdd() { initEJB(); assert "addInitialized".equals(myEjbSeam.prepareAddSomething()); } @AfterTest public void destroy() { System.out.println("aprs test"); } }"
If I extends SeamTest with the same code, I obtain this error:
DEBUG [main] (Lifecycle.java:261) - End of session, destroying contexts FAILED CONFIGURATION: @AfterMethod end java.lang.NullPointerException at org.jboss.seam.contexts.WebApplicationContext.get(WebApplicationContext.java:48) at org.jboss.seam.Component.forName(Component.java:1579) at org.jboss.seam.Component.getInstance(Component.java:1627) at org.jboss.seam.Component.getInstance(Component.java:1622) at org.jboss.seam.Component.getInstance(Component.java:1599) at org.jboss.seam.Component.getInstance(Component.java:1594) at org.jboss.seam.core.ConversationEntries.instance(ConversationEntries.java:91) at org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:284) at org.jboss.seam.mock.SeamTest.end(SeamTest.java:676) ... Removed 24 stack frames
I read the posts about this error, but anything i tried don't solve my problem.
I have Seam 1.2.1GA, TestNG 5.7 with Eclipse plugin.
I moved all -embedded.jar files in first position in the classpath without result.
I don't have two Seam jar files in the same classpath.
If anyone could help me...
Thanks in advance.