deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [1/3] git commit: DELTASPIKE-515 MockedJsfTestContainerAdapter
Date Thu, 20 Feb 2014 08:53:58 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master a56cbf844 -> ad9ed6d5a


DELTASPIKE-515 MockedJsfTestContainerAdapter


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/6734367a
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/6734367a
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/6734367a

Branch: refs/heads/master
Commit: 6734367a5b441e971258ae6ba611e5b9d335a926
Parents: a56cbf8
Author: gpetracek <gpetracek@apache.org>
Authored: Thu Feb 20 08:52:11 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Thu Feb 20 08:52:11 2014 +0100

----------------------------------------------------------------------
 .../impl/jsf/MockedJsfTestContainerAdapter.java | 97 ++------------------
 deltaspike/parent/pom.xml                       |  2 +-
 2 files changed, 9 insertions(+), 90 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/6734367a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MockedJsfTestContainerAdapter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MockedJsfTestContainerAdapter.java
b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MockedJsfTestContainerAdapter.java
index 23a7c60..a1e7f20 100644
--- a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MockedJsfTestContainerAdapter.java
+++ b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MockedJsfTestContainerAdapter.java
@@ -18,70 +18,24 @@
  */
 package org.apache.deltaspike.testcontrol.impl.jsf;
 
-import org.apache.deltaspike.core.util.ClassUtils;
-import org.apache.deltaspike.core.util.ExceptionUtils;
 import org.apache.deltaspike.testcontrol.spi.ExternalContainer;
+import org.apache.myfaces.test.mock.MockedJsfTestContainer;
 
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
 
 /**
  * Optional adapter for MockedJsfTestContainer
  * Requires MyFaces-Test v1.0.6 or higher
  */
-//TODO use MockedJsfTestContainer without reflection once v1.0.6 of myfaces-test is released
 public class MockedJsfTestContainerAdapter implements ExternalContainer
 {
-    private final Object mockedMyFacesTestContainer;
-
-    private final Method startContainerMethod;
-    private final Method stopContainerMethod;
-
-    private final Method startRequestMethod;
-    private final Method stopRequestMethod;
-
-    private final Method startSessionMethod;
-    private final Method stopSessionMethod;
-
-    public MockedJsfTestContainerAdapter()
-    {
-        this.mockedMyFacesTestContainer =
-            ClassUtils.tryToInstantiateClassForName("org.apache.myfaces.test.mock.MockedJsfTestContainer");
-
-        if (this.mockedMyFacesTestContainer == null)
-        {
-            throw new IllegalStateException("This adapter requires MyFaces-Test v1.0.6 or
higher.");
-        }
-
-        try
-        {
-            this.startContainerMethod = this.mockedMyFacesTestContainer.getClass().getDeclaredMethod("setUp");
-            this.stopContainerMethod = this.mockedMyFacesTestContainer.getClass().getDeclaredMethod("tearDown");
-
-            this.startRequestMethod = this.mockedMyFacesTestContainer.getClass().getDeclaredMethod("startRequest");
-            this.stopRequestMethod = this.mockedMyFacesTestContainer.getClass().getDeclaredMethod("endRequest");
-
-            this.startSessionMethod = this.mockedMyFacesTestContainer.getClass().getDeclaredMethod("startSession");
-            this.stopSessionMethod = this.mockedMyFacesTestContainer.getClass().getDeclaredMethod("endSession");
-        }
-        catch (NoSuchMethodException e)
-        {
-            throw ExceptionUtils.throwAsRuntimeException(e);
-        }
-    }
+    private final MockedJsfTestContainer mockedMyFacesTestContainer = new MockedJsfTestContainer();
 
     public void boot()
     {
-        try
-        {
-            this.startContainerMethod.invoke(this.mockedMyFacesTestContainer);
-        }
-        catch (Exception e)
-        {
-            throw ExceptionUtils.throwAsRuntimeException(e);
-        }
+        this.mockedMyFacesTestContainer.setUp();
     }
 
     @Override
@@ -89,25 +43,11 @@ public class MockedJsfTestContainerAdapter implements ExternalContainer
     {
         if (RequestScoped.class.equals(scopeClass))
         {
-            try
-            {
-                this.startRequestMethod.invoke(this.mockedMyFacesTestContainer);
-            }
-            catch (Exception e)
-            {
-                throw ExceptionUtils.throwAsRuntimeException(e);
-            }
+            this.mockedMyFacesTestContainer.startRequest();
         }
         else if (SessionScoped.class.equals(scopeClass))
         {
-            try
-            {
-                this.startSessionMethod.invoke(this.mockedMyFacesTestContainer);
-            }
-            catch (Exception e)
-            {
-                throw ExceptionUtils.throwAsRuntimeException(e);
-            }
+            this.mockedMyFacesTestContainer.startSession();
         }
     }
 
@@ -116,38 +56,17 @@ public class MockedJsfTestContainerAdapter implements ExternalContainer
     {
         if (RequestScoped.class.equals(scopeClass))
         {
-            try
-            {
-                this.stopRequestMethod.invoke(this.mockedMyFacesTestContainer);
-            }
-            catch (Exception e)
-            {
-                throw ExceptionUtils.throwAsRuntimeException(e);
-            }
+            this.mockedMyFacesTestContainer.endRequest();
         }
         else if (SessionScoped.class.equals(scopeClass))
         {
-            try
-            {
-                this.stopSessionMethod.invoke(this.mockedMyFacesTestContainer);
-            }
-            catch (Exception e)
-            {
-                throw ExceptionUtils.throwAsRuntimeException(e);
-            }
+            this.mockedMyFacesTestContainer.endSession();
         }
     }
 
     public void shutdown()
     {
-        try
-        {
-            this.stopContainerMethod.invoke(this.mockedMyFacesTestContainer);
-        }
-        catch (Exception e)
-        {
-            throw ExceptionUtils.throwAsRuntimeException(e);
-        }
+        this.mockedMyFacesTestContainer.tearDown();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/6734367a/deltaspike/parent/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml
index 3cdd4f4..a66993a 100644
--- a/deltaspike/parent/pom.xml
+++ b/deltaspike/parent/pom.xml
@@ -654,7 +654,7 @@
             <dependency>
                 <groupId>org.apache.myfaces.test</groupId>
                 <artifactId>myfaces-test20</artifactId>
-                <version>1.0.5</version>
+                <version>1.0.6</version>
                 <scope>provided</scope>
             </dependency>
 


Mime
View raw message