3 Replies Latest reply on Mar 29, 2008 4:03 PM by pmuir

    Wrong conversation component in integration tests

    larshuber

      I want to test my UserHome component defined for Conversation scope. With debugging I see that the component is created and initialized correctly through the call from pages.xml. And also at the end of the test the correct component is destroyed visibly by debugging.


      But in my test methods the instance I get is a new UserHome and is not initialized. It also doesn't @Destroy at the end of the test. In production mode the UserHome works correctly.


      Where is my real UserHome gone? Is my test wrong? As template I took tests from Wiki.


      Test


           @Test
           public void testRegisterUser() throws Exception {
                final String conversationId = new NonFacesRequest("/userRegister.xhtml") {
                     @Override
                     protected void renderResponse() throws Exception {
                          UserHome _home = (UserHome)getInstance("userHome");
                          assert isLongRunningConversation();
                     }
                }.run();
      
                new FacesRequest("/userRegister.xhtml", conversationId) {
                     @Override
                     protected void invokeApplication() throws Exception {
                          assert isLongRunningConversation();
                          UserHome _home = (UserHome) getInstance("userHome");
                          assert _home.getInstance() != null;
                     }
                }.run();
           }
      



      greets Lars


      pages.xml


           <page view-id="/userRegister*"
                no-conversation-view-id="/home.xhtml">
                <action execute="#{userHome.init}" />
                <begin-conversation flush-mode="MANUAL" join="true" />
                <navigation>
                     <rule if-outcome="persisted">
                          <end-conversation before-redirect="true" />
                          <redirect view-id="/pomop.xhtml">
                               <param name="message" value="pomop.msg.AccountCreatedConfirmationSent" />
                          </redirect>
                     </rule>
                </navigation>
           </page>