1 Reply Latest reply on Aug 28, 2009 7:58 PM by Juan Martin Chiaradia

    Testing method with Conversation.instance().begin(true, false);

    Juan Martin Chiaradia Newbie

      Hello, I am using testNG to test my Seam components.


      I'm having problems to test a component that init a conversation.


      The test fails when the conversation start:




      public abstract class UseCase implements Serializable {
      (...)
              public final UseCaseConstants begin() {
                      if (!this.active) {
                              this.active = true;
      
                              //HERE FAILS THE TEST:
                        Conversation.instance().begin(true, false);
      
                              Conversation.instance().changeFlushMode(FlushModeType.MANUAL);
                              this.initialize();
                              return UseCaseConstants.SUCCESS;
                      }
                      return UseCaseConstants.ALLREADY_STARTED;
              }
      (...)
      



      Here is the test:


      public class UseCaseTest extends SeamTest {
              
              @Test
              public void testBegin() throws Exception {
      
                      new ComponentTest() {
      
                              protected void testComponents() throws Exception {
                                      // Begin OK
                                      assert invokeMethod("#{useCaseManager.beginUC(new UseCase())}")
                                                      .equals(UseCaseConstants.SUCCESS);
                              }
      
                      }.run();
              }
      }




      Could anyone help me?


      Regards,
      Chaira


        • 1. Re: Testing method with Conversation.instance().begin(true, false);
          Juan Martin Chiaradia Newbie

          I forget to past the exception:




          javax.el.ELException: java.lang.IllegalArgumentException: Stack must not be null



          Here is the full stack trace:


          FAILED: testCrear
          javax.el.ELException: java.lang.IllegalArgumentException: Stack must not be null
               at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:339)
               at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:280)
               at org.jboss.el.parser.AstMethodSuffix.getValue(AstMethodSuffix.java:59)
               at org.jboss.el.parser.AstMethodSuffix.invoke(AstMethodSuffix.java:65)
               at org.jboss.el.parser.AstValue.invoke(AstValue.java:96)
               at org.jboss.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
               at org.jboss.seam.core.Expressions$2.invoke(Expressions.java:175)
               at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.invokeMethod(AbstractSeamTest.java:136)
               at TipoUnidadTest$1.testComponents(UseCaseTest.java:19)
               at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162)
               at UseCaseTest.testBegin(TipoUnidadTest.java:37)
          Caused by: java.lang.IllegalArgumentException: Stack must not be null
               at org.jboss.seam.core.ConversationEntry.<init>(ConversationEntry.java:45)
               at org.jboss.seam.core.ConversationEntries.createConversationEntry(ConversationEntries.java:53)
               at org.jboss.seam.core.Manager.createConversationEntry(Manager.java:664)
               at org.jboss.seam.core.Manager.beginConversation(Manager.java:685)
               at org.jboss.seam.core.Conversation.reallyBegin(Conversation.java:246)
               at org.jboss.seam.core.Conversation.begin(Conversation.java:282)
               at erk.bean.usecase.UseCase.begin(UseCase.java:31)
               at erk.bean.usecase.UseCaseMannager.beginUC(UseCaseMannager.java:142)
               at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
               at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
               at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.core.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:32)
               at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
               at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
               at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
               at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
               at erk.bean.usecase.UseCaseMannager_$$_javassist_seam_1.beginUC(UseCaseMannager_$$_javassist_seam_1.java)
               at org.jboss.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:335)
               ... 32 more
          ... Removed 30 stack frames