[jboss-cvs] jboss-seam/src/main/org/jboss/seam/mock ...

Gavin King gavin.king at jboss.com
Thu Nov 9 00:47:49 EST 2006


  User: gavin   
  Date: 06/11/09 00:47:49

  Modified:    src/main/org/jboss/seam/mock  SeamTest.java
  Log:
  fix JBSEAM-452 and unit test
  
  Revision  Changes    Path
  1.55      +33 -19    jboss-seam/src/main/org/jboss/seam/mock/SeamTest.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: SeamTest.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/mock/SeamTest.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -b -r1.54 -r1.55
  --- SeamTest.java	3 Nov 2006 22:47:25 -0000	1.54
  +++ SeamTest.java	9 Nov 2006 05:47:49 -0000	1.55
  @@ -24,11 +24,9 @@
   import org.hibernate.validator.ClassValidator;
   import org.hibernate.validator.InvalidValue;
   import org.jboss.seam.Component;
  -import org.jboss.seam.Seam;
   import org.jboss.seam.contexts.Contexts;
   import org.jboss.seam.contexts.Lifecycle;
   import org.jboss.seam.core.FacesMessages;
  -import org.jboss.seam.core.FacesPage;
   import org.jboss.seam.core.Init;
   import org.jboss.seam.core.Manager;
   import org.jboss.seam.core.Pageflow;
  @@ -49,7 +47,7 @@
    * 
    * @author Gavin King
    * @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
  - * @version $Revision: 1.54 $
  + * @version $Revision: 1.55 $
    */
   public class SeamTest
   {
  @@ -369,7 +367,7 @@
            
            UIViewRoot viewRoot = facesContext.getApplication().getViewHandler().createView( facesContext, getViewId() );
            facesContext.setViewRoot(viewRoot);
  -         Map viewRootAttributes = facesContext.getViewRoot().getAttributes();
  +         Map restoredViewRootAttributes = facesContext.getViewRoot().getAttributes();
            if ( conversationId!=null )
            {
               if ( isGetRequest() ) 
  @@ -383,15 +381,17 @@
                  {
                     //should really only do this if the view id matches (not really possible to implement)
                     Map state = conversationViewRootAttributes.get(conversationId);
  -                  viewRootAttributes.putAll(state);
  +                  restoredViewRootAttributes.putAll(state);
                  }
               }
            }
            if ( !isGetRequest() )
            {
  -            viewRootAttributes.putAll(pageParameters);
  +            restoredViewRootAttributes.putAll(pageParameters);
            }
            
  +         updateConversationId();
  +         
            phases.afterPhase( new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, MockLifecycle.INSTANCE) );
            
            if ( !isGetRequest() && !skipToRender() )
  @@ -401,6 +401,8 @@
               
               applyRequestValues();
         
  +            updateConversationId();
  +      
               phases.afterPhase( new PhaseEvent(facesContext, PhaseId.APPLY_REQUEST_VALUES, MockLifecycle.INSTANCE) );
               
               if ( !skipToRender() )
  @@ -410,6 +412,8 @@
                  
                  processValidations();
                  
  +               updateConversationId();
  +               
                  phases.afterPhase( new PhaseEvent(facesContext, PhaseId.PROCESS_VALIDATIONS, MockLifecycle.INSTANCE) );
      
                  if ( !skipToRender() )
  @@ -419,6 +423,8 @@
                     
                     updateModelValues();
               
  +                  updateConversationId();
  +            
                     phases.afterPhase( new PhaseEvent(facesContext, PhaseId.UPDATE_MODEL_VALUES, MockLifecycle.INSTANCE) );
      
                     if ( !skipToRender() )
  @@ -437,6 +443,8 @@
                        
                        viewId = getRenderedViewId();
               
  +                     updateConversationId();
  +                     
                        phases.afterPhase( new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE) );
                        
                     }
  @@ -447,7 +455,11 @@
               
            }
            
  -         if ( !skipRender() )
  +         if ( skipRender() )
  +         {
  +            //we really should look at redirect parameters here!
  +         }
  +         else
            {
            
               phases.beforePhase( new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE) );
  @@ -460,28 +472,30 @@
               
               facesContext.getApplication().getStateManager().saveSerializedView(facesContext);
               
  -            phases.afterPhase( new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE ) );
  -            
  -         }
  +            updateConversationId();
            
  -         afterRequest();
  +            phases.afterPhase( new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE) );
   
  -         Map attributes = viewRootAttributes;
  -         if (attributes!=null)
  -         {
  -            FacesPage facesPage = (FacesPage) attributes.get( Seam.getComponentName(FacesPage.class) );
  -            if (facesPage!=null)
  +            Map renderedViewRootAttributes = facesContext.getViewRoot().getAttributes();
  +            if (renderedViewRootAttributes!=null)
               {
  -               conversationId = facesPage.getConversationId();
                  Map conversationState = new HashMap();
  -               conversationState.putAll(attributes);
  +               conversationState.putAll(renderedViewRootAttributes);
                  conversationViewRootAttributes.put(conversationId, conversationState);
               }
  +
            }
   
  +         afterRequest();
  +
            return conversationId;
         }
   
  +      private void updateConversationId()
  +      {
  +         conversationId = Manager.instance().getCurrentConversationId();
  +      }
  +
         private boolean skipRender()
         {
            return FacesContext.getCurrentInstance().getResponseComplete();
  
  
  



More information about the jboss-cvs-commits mailing list