[jboss-user] [JBoss Seam] - Re: TestNG , EntityHome , No application context active
laurence_kirk
do-not-reply at jboss.com
Sun Jun 3 15:05:25 EDT 2007
this is the test code
The persist does succeed, and I get a row in the db, so I'm assuming its something about TestNG that I havent get set up correctly.
| @Test
| public final void testCreate()
| {
|
| EntityManagerFactory emf = Persistence.createEntityManagerFactory("entityManager");
| System.out.println("created emf "+ emf);
| EntityManager em = emf.createEntityManager();
| TestEntityHome teh = new TestEntityHome();
|
| teh.setEntityManager(em);
| em.getTransaction().begin();
| TestEntity te = teh.createInstance();
| te.setId(12);
| teh.setInstance(te);
| teh.getInstance();
| teh.persist();
| em.getTransaction().commit();
|
|
| }
|
TestEntityHome is a sublcass of Entity Home as follows
| public class TestEntityHome<E> extends EntityHome
| {
|
| @Override
| public TestEntity createInstance()
| {
|
| TestEntity te = new TestEntity();
| return te;
| }
|
| }
|
anonymous wrote :
| [testng] 20:07:10,359 INFO [SchemaUpdate] schema update complete
| [testng] created emf org.hibernate.ejb.EntityManagerFactoryImpl at 186d484
| [testng] 20:07:10,625 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://*********
| [testng] 20:07:10,640 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://***********
| [testng] 20:07:10,843 WARN [AbstractEntityManagerImpl] Calling joinTransaction() on a non JTA EntityManager
| [testng] Hibernate: insert into XTEST (name, id) values (?, ?)
| [testng] Creating E:\jbossseam\dev\testp1\test-report\Entity Home Test.html
| [testng] FAILED: org.jboss.seam.mock.SeamTest.end()
| [testng] java.lang.NullPointerException
| [testng] at org.jboss.seam.contexts.WebApplicationContext.get(WebApplicationContext.java:48)
| [testng] at org.jboss.seam.Component.forName(Component.java:1579)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1627)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1622)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1599)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1594)
| [testng] at org.jboss.seam.core.ConversationEntries.instance(ConversationEntries.java:91)
| [testng] at org.jboss.seam.contexts.Lifecycle.endSession(Lifecycle.java:284)
| [testng] at org.jboss.seam.mock.SeamTest.end(SeamTest.java:676)
| [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| [testng] at java.lang.reflect.Method.invoke(Method.java:585)
| [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
| [testng] at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:311)
| [testng] at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:149)
| [testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:467)
| [testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
| [testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
| [testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
| [testng] at org.testng.TestRunner.run(TestRunner.java:505)
| [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
| [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
| [testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
| [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
| [testng] at org.testng.TestNG.run(TestNG.java:316)
| [testng] at org.testng.TestNG.privateMain(TestNG.java:666)
| [testng] at org.testng.TestNG.main(TestNG.java:608)
| [testng] FAILED: test.ActualTestClass.testCreate()
| [testng] java.lang.IllegalStateException: No application context active
| [testng] at org.jboss.seam.Component.forName(Component.java:1577)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1627)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1622)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1599)
| [testng] at org.jboss.seam.Component.getInstance(Component.java:1594)
| [testng] at org.jboss.seam.persistence.PersistenceProvider.instance(PersistenceProvider.java:56)
| [testng] at org.jboss.seam.framework.EntityHome.persist(EntityHome.java:50)
| [testng] at test.ActualTestClass.testCreate(ActualTestClass.java:63)
| [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| [testng] at java.lang.reflect.Method.invoke(Method.java:585)
| [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
| [testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:398)
| [testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
| [testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
| [testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
| [testng] at org.testng.TestRunner.run(TestRunner.java:505)
| [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
| [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
| [testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
| [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
| [testng] at org.testng.TestNG.run(TestNG.java:316)
| [testng] at org.testng.TestNG.privateMain(TestNG.java:666)
| [testng] at org.testng.TestNG.main(TestNG.java:608)
| [testng] SKIPPED: destroy
| [testng] SKIPPED: cleanup
| [testng] ===============================================
| [testng] Entity Home Test
| [testng] Tests run: 4, Failures: 2, Skips: 2
| [testng] ===============================================
| [testng] Creating E:\jbossseam\dev\testp1\test-report\testng-failed.xml
| [testng] ===============================================
| [testng] Entity Home
| [testng] Total tests run: 4, Failures: 2, Skips: 2
| [testng] ===============================================
| [testng] Creating E:\jbossseam\dev\testp1\test-report\toc.html
| [testng] Creating E:\jbossseam\dev\testp1\test-report\Entity Home Test.properties
| [testng] Creating E:\jbossseam\dev\testp1\test-report\index.html
| [testng] Creating E:\jbossseam\dev\testp1\test-report\main.html
| [testng] Creating E:\jbossseam\dev\testp1\test-report\groups.html
| [testng] Creating E:\jbossseam\dev\testp1\test-report\methods.html
| [testng] Creating E:\jbossseam\dev\testp1\test-report\classes.html
| BUILD SUCCESSFUL
| Total time: 21 seco
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4050761#4050761
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4050761
More information about the jboss-user
mailing list