0 Replies Latest reply on Aug 31, 2007 2:14 PM by Matthew Lieder

    NPE when using SeamTest (v2.0)

    Matthew Lieder Apprentice

      I have the following test class:

      package com.fl.bpm_ui.scheduler;
      
      import org.jboss.seam.core.Manager;
      import org.jboss.seam.mock.SeamTest;
      import org.junit.*;
      
      public class InitialCallTest extends SeamTest
      {
       @Test
       public void testNumberGuessWin() throws Exception
       {
       String id = new NonFacesRequest("/scheduler/usher.seam?flow=initialCall")
       {
      
       @Override
       protected void renderResponse() throws Exception {
       CallManager cm = (CallManager) getInstance(CallManager.class);
       assert Manager.instance().isLongRunningConversation();
       }
      
       }.run();
       }
      }


      And get the following error:
      -------------------------------------------------------------------------------
      Test set: com.fl.bpm_ui.scheduler.InitialCallTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.047 sec <<< FAILURE!
      testNumberGuessWin(com.fl.bpm_ui.scheduler.InitialCallTest) Time elapsed: 0.016 sec <<< ERROR!
      java.lang.NullPointerException
       at org.jboss.seam.mock.BaseSeamTest$Request.run(BaseSeamTest.java:504)
       at com.fl.bpm_ui.scheduler.InitialCallTest.testNumberGuessWin(InitialCallTest.java:24)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.junit.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)
       at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)
       at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
       at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)
       at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)
       at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:71)
       at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)
       at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)
       at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)
       at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
       at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
       at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
       at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
       at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:314)
       at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:907)


      Running through the debugger, it seems the NPE is happening on the "FacesLifecycle.endRequest(externalContext);" line in the finally block in the run() method.

      Any ideas how I can fix this?