[jboss-cvs] jboss-seam/src/main/org/jboss/seam/mock ...
Gavin King
gavin.king at jboss.com
Thu Oct 26 13:54:12 EDT 2006
User: gavin
Date: 06/10/26 13:54:12
Modified: src/main/org/jboss/seam/mock SeamTest.java
Log:
helper methods
Revision Changes Path
1.47 +32 -11 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.46
retrieving revision 1.47
diff -u -b -r1.46 -r1.47
--- SeamTest.java 26 Oct 2006 13:36:45 -0000 1.46
+++ SeamTest.java 26 Oct 2006 17:54:12 -0000 1.47
@@ -10,6 +10,7 @@
import java.util.HashMap;
import java.util.Map;
+import javax.faces.application.Application;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
@@ -44,7 +45,7 @@
*
* @author Gavin King
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
- * @version $Revision: 1.46 $
+ * @version $Revision: 1.47 $
*/
public class SeamTest
{
@@ -56,6 +57,11 @@
private MockHttpSession session;
private Map<String, Map> conversationViewRootAttributes;
+ protected void setParameter(String name, String value)
+ {
+ getParameters().put( name, new String[] {value} );
+ }
+
protected Map<String, String[]> getParameters()
{
return ( (MockHttpServletRequest) externalContext.getRequest() ).getParameters();
@@ -111,6 +117,7 @@
private boolean renderResponseComplete;
private boolean invokeApplicationBegun;
private boolean invokeApplicationComplete;
+ private Application application;
/**
* A script for a JSF interaction with
@@ -263,10 +270,28 @@
}
/**
- * Test harness cannot currently evaluate EL, so for a temporary
- * solution, call page actions here.
+ * Evaluate (get) a value binding
+ */
+ protected Object getValue(String valueExpression)
+ {
+ return application.createValueBinding(valueExpression).getValue(facesContext);
+ }
+
+ /**
+ * Set a value binding
*/
- protected void callPageActions() throws Exception {}
+ protected void setValue(String valueExpression, Object value)
+ {
+ application.createValueBinding(valueExpression).setValue(facesContext, value);
+ }
+
+ /**
+ * Call a method binding
+ */
+ protected Object invokeMethod(String methodExpression)
+ {
+ return application.createMethodBinding(methodExpression, null).invoke(facesContext, null);
+ }
/**
* @return the conversation id
@@ -275,7 +300,8 @@
public String run() throws Exception
{
externalContext = new MockExternalContext(servletContext, session);
- facesContext = new MockFacesContext( externalContext, new SeamApplication11(application) );
+ application = new SeamApplication11(SeamTest.this.application);
+ facesContext = new MockFacesContext( externalContext, application );
facesContext.setCurrent();
beforeRequest();
@@ -361,11 +387,6 @@
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();
More information about the jboss-cvs-commits
mailing list