myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r959478 - in /myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test: base/AbstractJsfTestCase.java jmock/AbstractJmockJsfTestCase.java
Date Thu, 01 Jul 2010 00:20:39 GMT
Author: lu4242
Date: Thu Jul  1 00:20:39 2010
New Revision: 959478

URL: http://svn.apache.org/viewvc?rev=959478&view=rev
Log:
MYFACESTEST-18 Include in AbstractJsfTestCase and AbstractJmockTestCase protected methods
for setup elements and allow better customization

Modified:
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
    myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java?rev=959478&r1=959477&r2=959478&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
Thu Jul  1 00:20:39 2010
@@ -101,6 +101,23 @@ public abstract class AbstractJsfTestCas
                 this.getClass().getClassLoader()));
 
         // Set up Servlet API Objects
+        setUpServletObjects();
+
+        // Set up JSF API Objects
+        FactoryFinder.releaseFactories();
+
+        setFactories();
+
+        setUpExternalContext();
+        setUpLifecycle();
+        setUpFacesContext();
+        setUpView();
+        setUpApplication();
+        setUpRenderKit();
+    }
+    
+    protected void setUpServletObjects() throws Exception 
+    {
         servletContext = new MockServletContext();
         config = new MockServletConfig(servletContext);
         session = new MockHttpSession();
@@ -108,9 +125,10 @@ public abstract class AbstractJsfTestCas
         request = new MockHttpServletRequest(session);
         request.setServletContext(servletContext);
         response = new MockHttpServletResponse();
-
-        // Set up JSF API Objects
-        FactoryFinder.releaseFactories();
+    }
+    
+    protected void setFactories() throws Exception 
+    {
         FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
         "org.apache.myfaces.test.mock.MockApplicationFactory");
         FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
@@ -119,13 +137,24 @@ public abstract class AbstractJsfTestCas
         "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
         FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
         "org.apache.myfaces.test.mock.MockRenderKitFactory");
-
+    }
+    
+    protected void setUpExternalContext() throws Exception
+    {
         externalContext =
             new MockExternalContext(servletContext, request, response);
+    }
+    
+    protected void setUpLifecycle() throws Exception
+    {
         lifecycleFactory = (MockLifecycleFactory)
         FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         lifecycle = (MockLifecycle)
         lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    }
+    
+    protected void setUpFacesContext() throws Exception
+    {
         facesContextFactory = (MockFacesContextFactory)
         FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
         facesContext = (MockFacesContext)
@@ -134,22 +163,32 @@ public abstract class AbstractJsfTestCas
                 response,
                 lifecycle);
         externalContext = (MockExternalContext) facesContext.getExternalContext();
+    }
+
+    protected void setUpView() throws Exception
+    {
         UIViewRoot root = new UIViewRoot();
         root.setViewId("/viewId");
         root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
         facesContext.setViewRoot(root);
+    }
+    
+    protected void setUpApplication() throws Exception
+    {
         ApplicationFactory applicationFactory = (ApplicationFactory)
-          FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
         application = (MockApplication) applicationFactory.getApplication();
         facesContext.setApplication(application);
+    }
+    
+    protected void setUpRenderKit() throws Exception
+    {
         RenderKitFactory renderKitFactory = (RenderKitFactory)
         FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
         renderKit = new MockRenderKit();
         renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
-
     }
 
-
     /**
      * <p>Tear down instance variables required by this test case.</p>
      */

Modified: myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
URL: http://svn.apache.org/viewvc/myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java?rev=959478&r1=959477&r2=959478&view=diff
==============================================================================
--- myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
(original)
+++ myfaces/test/trunk/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
Thu Jul  1 00:20:39 2010
@@ -94,6 +94,25 @@ public abstract class AbstractJmockJsfTe
                 this.getClass().getClassLoader()));
         
         // Set up Servlet API Objects
+        setUpServletObjects();
+        
+        // Set up JSF API Objects
+        FactoryFinder.releaseFactories();
+        
+        setFactories();
+        
+        setFactories();
+
+        setUpExternalContext();
+        setUpLifecycle();
+        setUpFacesContext();
+        setUpView();
+        setUpApplication();
+        setUpRenderKit();
+    }
+    
+    protected void setUpServletObjects() throws Exception 
+    {
         servletContext = new MockServletContext();
         config = new MockServletConfig(servletContext);
         session = new MockHttpSession();
@@ -101,9 +120,10 @@ public abstract class AbstractJmockJsfTe
         request = new MockHttpServletRequest(session);
         request.setServletContext(servletContext);
         response = new MockHttpServletResponse();
-        
-        // Set up JSF API Objects
-        FactoryFinder.releaseFactories();
+    }
+    
+    protected void setFactories() throws Exception 
+    {
         FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
         "org.apache.myfaces.test.mock.MockApplicationFactory");
         FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
@@ -112,13 +132,24 @@ public abstract class AbstractJmockJsfTe
         "org.apache.myfaces.test.mock.lifecycle.MockLifecycleFactory");
         FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
         "org.apache.myfaces.test.mock.MockRenderKitFactory");
-        
+    }
+    
+    protected void setUpExternalContext() throws Exception
+    {
         externalContext =
             new MockExternalContext(servletContext, request, response);
+    }
+    
+    protected void setUpLifecycle() throws Exception
+    {
         lifecycleFactory = (MockLifecycleFactory)
         FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
         lifecycle = (MockLifecycle)
         lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
+    }
+    
+    protected void setUpFacesContext() throws Exception
+    {
         facesContextFactory = (MockFacesContextFactory)
         FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
         facesContext = (MockFacesContext)
@@ -127,19 +158,30 @@ public abstract class AbstractJmockJsfTe
                 response,
                 lifecycle);
         externalContext = (MockExternalContext) facesContext.getExternalContext();
+    }
+
+    protected void setUpView() throws Exception
+    {
         UIViewRoot root = new UIViewRoot();
         root.setViewId("/viewId");
         root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
         facesContext.setViewRoot(root);
+    }
+    
+    protected void setUpApplication() throws Exception
+    {
         ApplicationFactory applicationFactory = (ApplicationFactory)
-          FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
+        FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
         application = (MockApplication) applicationFactory.getApplication();
         facesContext.setApplication(application);
+    }
+    
+    protected void setUpRenderKit() throws Exception
+    {
         RenderKitFactory renderKitFactory = (RenderKitFactory)
         FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
         renderKit = new MockRenderKit();
         renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
-        
     }
 
     // Tear down instance variables required by this test case.



Mime
View raw message