You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@apache.org on 2005/07/07 23:35:51 UTC
svn commit: r209653 - in
/struts/shale/trunk/test-framework/src/java/org/apache/shale/test:
base/AbstractJsfTestCase.java mock/MockFacesContextFactory.java
Author: craigmcc
Date: Thu Jul 7 14:35:48 2005
New Revision: 209653
URL: http://svn.apache.org/viewcvs?rev=209653&view=rev
Log:
Flesh out the simulation of the JSF environment by registering all of the
relevant factories, so we can test remote commands that need them.
Modified:
struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractJsfTestCase.java
struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockFacesContextFactory.java
Modified: struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractJsfTestCase.java?rev=209653&r1=209652&r2=209653&view=diff
==============================================================================
--- struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractJsfTestCase.java (original)
+++ struts/shale/trunk/test-framework/src/java/org/apache/shale/test/base/AbstractJsfTestCase.java Thu Jul 7 14:35:48 2005
@@ -24,6 +24,7 @@
import javax.faces.el.MethodNotFoundException;
import javax.faces.el.PropertyNotFoundException;
import javax.faces.el.ValueBinding;
+import javax.faces.lifecycle.LifecycleFactory;
import javax.faces.render.RenderKit;
import javax.faces.render.RenderKitFactory;
@@ -41,10 +42,12 @@
import org.apache.shale.test.mock.MockApplicationFactory;
import org.apache.shale.test.mock.MockExternalContext;
import org.apache.shale.test.mock.MockFacesContext;
+import org.apache.shale.test.mock.MockFacesContextFactory;
import org.apache.shale.test.mock.MockHttpServletRequest;
import org.apache.shale.test.mock.MockHttpServletResponse;
import org.apache.shale.test.mock.MockHttpSession;
import org.apache.shale.test.mock.MockLifecycle;
+import org.apache.shale.test.mock.MockLifecycleFactory;
import org.apache.shale.test.mock.MockRenderKit;
import org.apache.shale.test.mock.MockRenderKitFactory;
import org.apache.shale.test.mock.MockServletConfig;
@@ -102,13 +105,27 @@
// Set up JSF API Objects
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
"org.apache.shale.test.mock.MockApplicationFactory");
+ FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
+ "org.apache.shale.test.mock.MockFacesContextFactory");
+ FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
+ "org.apache.shale.test.mock.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
"org.apache.shale.test.mock.MockRenderKitFactory");
externalContext =
new MockExternalContext(servletContext, request, response);
- lifecycle = new MockLifecycle();
- facesContext = new MockFacesContext(externalContext, lifecycle);
+ lifecycleFactory = (MockLifecycleFactory)
+ FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
+ lifecycle = (MockLifecycle)
+ lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+ facesContextFactory = (MockFacesContextFactory)
+ FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
+ facesContext = (MockFacesContext)
+ facesContextFactory.getFacesContext(servletContext,
+ request,
+ response,
+ lifecycle);
+ externalContext = (MockExternalContext) facesContext.getExternalContext();
UIViewRoot root = new UIViewRoot();
root.setViewId("/viewId");
facesContext.setViewRoot(root);
@@ -146,6 +163,7 @@
externalContext = null;
facesContext = null;
lifecycle = null;
+ lifecycleFactory = null;
renderKit = null;
request = null;
response = null;
@@ -163,7 +181,9 @@
protected MockServletConfig config = null;
protected MockExternalContext externalContext = null;
protected MockFacesContext facesContext = null;
+ protected MockFacesContextFactory facesContextFactory = null;
protected MockLifecycle lifecycle = null;
+ protected MockLifecycleFactory lifecycleFactory = null;
protected MockRenderKit renderKit = null;
protected MockHttpServletRequest request = null;
protected MockHttpServletResponse response = null;
Modified: struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockFacesContextFactory.java
URL: http://svn.apache.org/viewcvs/struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockFacesContextFactory.java?rev=209653&r1=209652&r2=209653&view=diff
==============================================================================
--- struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockFacesContextFactory.java (original)
+++ struts/shale/trunk/test-framework/src/java/org/apache/shale/test/mock/MockFacesContextFactory.java Thu Jul 7 14:35:48 2005
@@ -21,6 +21,9 @@
import javax.faces.context.FacesContextFactory;
import javax.faces.context.FacesContext;
import javax.faces.lifecycle.Lifecycle;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
/**
* <p>Mock implementation of <code>FacesContextFactory</code>.</p>
@@ -53,7 +56,11 @@
Object response,
Lifecycle lifecycle) throws FacesException {
- return new MockFacesContext();
+ MockExternalContext externalContext =
+ new MockExternalContext((ServletContext) context,
+ (HttpServletRequest) request,
+ (HttpServletResponse) response);
+ return new MockFacesContext(externalContext, lifecycle);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org