[jboss-cvs] jboss-seam/src/main/org/jboss/seam/mock ...
Gavin King
gavin.king at jboss.com
Thu Oct 26 09:36:45 EDT 2006
User: gavin
Date: 06/10/26 09:36:45
Modified: src/main/org/jboss/seam/mock MockNavigationHandler.java
SeamTest.java
Log:
again improve the test harness
Revision Changes Path
1.2 +1 -1 jboss-seam/src/main/org/jboss/seam/mock/MockNavigationHandler.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MockNavigationHandler.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/mock/MockNavigationHandler.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- MockNavigationHandler.java 19 Apr 2006 01:43:53 -0000 1.1
+++ MockNavigationHandler.java 26 Oct 2006 13:36:45 -0000 1.2
@@ -7,7 +7,7 @@
{
@Override
- public void handleNavigation(FacesContext arg0, String arg1, String arg2)
+ public void handleNavigation(FacesContext context, String action, String outcome)
{
}
1.46 +64 -31 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.45
retrieving revision 1.46
diff -u -b -r1.45 -r1.46
--- SeamTest.java 25 Oct 2006 23:29:14 -0000 1.45
+++ SeamTest.java 26 Oct 2006 13:36:45 -0000 1.46
@@ -29,6 +29,7 @@
import org.jboss.seam.core.Manager;
import org.jboss.seam.core.Pageflow;
import org.jboss.seam.init.Initialization;
+import org.jboss.seam.jsf.SeamApplication11;
import org.jboss.seam.jsf.SeamNavigationHandler;
import org.jboss.seam.jsf.SeamPhaseListener;
import org.jboss.seam.jsf.SeamStateManager;
@@ -43,7 +44,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.45 $
+ * @version $Revision: 1.46 $
*/
public class SeamTest
{
@@ -105,7 +106,11 @@
private String outcome;
private boolean validationFailed;
private MockFacesContext facesContext;
-
+ private String viewId;
+ private boolean renderResponseBegun;
+ private boolean renderResponseComplete;
+ private boolean invokeApplicationBegun;
+ private boolean invokeApplicationComplete;
/**
* A script for a JSF interaction with
@@ -143,7 +148,12 @@
*/
protected String getViewId()
{
- return null;
+ return viewId;
+ }
+
+ protected void setViewId(String viewId)
+ {
+ this.viewId = viewId;
}
/**
@@ -194,7 +204,7 @@
/**
* Make some assertions, after the end of the request.
*/
- protected void afterRequest(boolean skippedRender, String viewId) {}
+ protected void afterRequest() {}
/**
* Do anything you like, after the start of the request.
* Especially, set up any request parameters for the
@@ -234,6 +244,9 @@
}
}
+ /**
+ * Did a validation failure occur during a call to validate()?
+ */
protected boolean isValidationFailure()
{
return validationFailed;
@@ -250,13 +263,19 @@
}
/**
+ * Test harness cannot currently evaluate EL, so for a temporary
+ * solution, call page actions here.
+ */
+ protected void callPageActions() throws Exception {}
+
+ /**
* @return the conversation id
* @throws Exception to fail the test
*/
public String run() throws Exception
{
externalContext = new MockExternalContext(servletContext, session);
- facesContext = new MockFacesContext(externalContext, application);
+ facesContext = new MockFacesContext( externalContext, new SeamApplication11(application) );
facesContext.setCurrent();
beforeRequest();
@@ -284,8 +303,6 @@
phases.afterPhase( new PhaseEvent(facesContext, PhaseId.RESTORE_VIEW, MockLifecycle.INSTANCE) );
- String renderedViewId = getRenderedViewId();
-
if ( !isGetRequest() && !skipToRender() )
{
@@ -318,12 +335,16 @@
phases.beforePhase( new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE) );
+ invokeApplicationBegun = true;
+
invokeApplication();
+ invokeApplicationComplete = true;
+
String outcome = getInvokeApplicationOutcome();
facesContext.getApplication().getNavigationHandler().handleNavigation(facesContext, null, outcome);
- renderedViewId = getRenderedViewId();
+ viewId = getRenderedViewId();
phases.afterPhase( new PhaseEvent(facesContext, PhaseId.INVOKE_APPLICATION, MockLifecycle.INSTANCE) );
@@ -335,21 +356,29 @@
}
- boolean skipRender = skipRender();
- if ( !skipRender )
+ if ( !skipRender() )
{
phases.beforePhase( new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE) );
+ //TODO: fix temp hack!
+ Lifecycle.setPhaseId(PhaseId.INVOKE_APPLICATION);
+ callPageActions();
+ Lifecycle.setPhaseId(PhaseId.RENDER_RESPONSE);
+
+ renderResponseBegun = true;
+
renderResponse();
+ renderResponseComplete = true;
+
facesContext.getApplication().getStateManager().saveSerializedView(facesContext);
phases.afterPhase( new PhaseEvent(facesContext, PhaseId.RENDER_RESPONSE, MockLifecycle.INSTANCE ) );
}
- afterRequest(skipRender, renderedViewId);
+ afterRequest();
Map attributes = facesContext.getViewRoot().getAttributes();
if (attributes!=null)
@@ -374,12 +403,30 @@
FacesContext.getCurrentInstance().getResponseComplete();
}
+ protected boolean isInvokeApplicationBegun()
+ {
+ return invokeApplicationBegun;
}
- public class NonFacesRequest extends Script
+ protected boolean isInvokeApplicationComplete()
{
- private String viewId;
+ return invokeApplicationComplete;
+ }
+
+ protected boolean isRenderResponseBegun()
+ {
+ return renderResponseBegun;
+ }
+
+ protected boolean isRenderResponseComplete()
+ {
+ return renderResponseComplete;
+ }
+
+ }
+ public class NonFacesRequest extends Script
+ {
public NonFacesRequest() {}
/**
@@ -387,7 +434,7 @@
*/
public NonFacesRequest(String viewId)
{
- this.viewId = viewId;
+ setViewId(viewId);
}
/**
@@ -397,7 +444,7 @@
public NonFacesRequest(String viewId, String conversationId)
{
super(conversationId);
- this.viewId = viewId;
+ setViewId(viewId);
}
@Override
@@ -424,19 +471,11 @@
throw new UnsupportedOperationException();
}
- @Override
- protected final String getViewId()
- {
- return viewId;
- }
-
}
public class FacesRequest extends Script
{
- private String viewId;
-
public FacesRequest() {}
/**
@@ -444,7 +483,7 @@
*/
public FacesRequest(String viewId)
{
- this.viewId = viewId;
+ setViewId(viewId);
}
/**
@@ -454,7 +493,7 @@
public FacesRequest(String viewId, String conversationId)
{
super(conversationId);
- this.viewId = viewId;
+ setViewId(viewId);
}
@Override
@@ -463,12 +502,6 @@
return false;
}
- @Override
- protected final String getViewId()
- {
- return viewId;
- }
-
}
@Configuration(beforeTestMethod=true)
More information about the jboss-cvs-commits
mailing list