You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2018/05/03 18:26:44 UTC

[myfaces-test] 16/24: MYFACESTEST-18 Include in AbstractJsfTestCase and AbstractJmockTestCase protected methods for setup elements and allow better customization

This is an automated email from the ASF dual-hosted git repository.

deki pushed a commit to branch 1_0_0_beta_4
in repository https://gitbox.apache.org/repos/asf/myfaces-test.git

commit 7dfcc08011d89479df8ba35b57a622b49f757914
Author: Leonardo Uribe <lu...@apache.org>
AuthorDate: Thu Jul 1 00:20:39 2010 +0000

    MYFACESTEST-18 Include in AbstractJsfTestCase and AbstractJmockTestCase protected methods for setup elements and allow better customization
---
 .../myfaces/test/base/AbstractJsfTestCase.java     | 53 ++++++++++++++++++---
 .../test/jmock/AbstractJmockJsfTestCase.java       | 54 +++++++++++++++++++---
 2 files changed, 94 insertions(+), 13 deletions(-)

diff --git a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
index 609a57b..4c11900 100644
--- a/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/base/AbstractJsfTestCase.java
@@ -101,6 +101,23 @@ public abstract class AbstractJsfTestCase extends TestCase {
                 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 AbstractJsfTestCase extends TestCase {
         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 AbstractJsfTestCase extends TestCase {
         "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 AbstractJsfTestCase extends TestCase {
                 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>
      */
diff --git a/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java b/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
index 309f526..eb7d4c8 100644
--- a/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
+++ b/test12/src/main/java/org/apache/myfaces/test/jmock/AbstractJmockJsfTestCase.java
@@ -94,6 +94,25 @@ public abstract class AbstractJmockJsfTestCase extends MockObjectTestCase {
                 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 AbstractJmockJsfTestCase extends MockObjectTestCase {
         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 AbstractJmockJsfTestCase extends MockObjectTestCase {
         "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 AbstractJmockJsfTestCase extends MockObjectTestCase {
                 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.

-- 
To stop receiving notification emails like this one, please contact
deki@apache.org.