deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [2/2] git commit: DELTASPIKE-514 optional integration with myfaces-core 2.2
Date Mon, 19 May 2014 21:10:49 GMT
DELTASPIKE-514 optional integration with myfaces-core 2.2


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

Branch: refs/heads/master
Commit: ce629272a40dd3b5ef3889d613190ff8366fc7d3
Parents: c04453c
Author: gpetracek <gpetracek@apache.org>
Authored: Mon May 19 20:49:53 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Mon May 19 23:02:39 2014 +0200

----------------------------------------------------------------------
 .../testcontrol/api/junit/CdiTestRunner.java    |  12 +-
 deltaspike/modules/test-control/impl/pom.xml    |   6 +
 .../impl/jsf/MyFacesContainerAdapter.java       | 114 +++++++++++++++
 .../MyFacesContainerPerTestMethodAdapter.java   |  84 +++++++++++
 .../InternalMyFacesTestContainerAdapter.java    | 127 ++++++++++++++++
 .../testcontrol/uc005/JsfContainerTest.java     | 114 ---------------
 .../uc005/MockedJsfContainerTest.java           | 114 +++++++++++++++
 .../testcontrol/uc009/JsfContainerTest.java     | 143 +++++++++++++++++++
 .../uc010/JsfContainerPerTestMethodTest.java    |  68 +++++++++
 ...deltaspike.testcontrol.spi.ExternalContainer |   2 +-
 deltaspike/parent/pom.xml                       |  13 +-
 11 files changed, 678 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
index 093751d..195045b 100644
--- a/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
+++ b/deltaspike/modules/test-control/api/src/main/java/org/apache/deltaspike/testcontrol/api/junit/CdiTestRunner.java
@@ -18,6 +18,7 @@
  */
 package org.apache.deltaspike.testcontrol.api.junit;
 
+import junit.framework.Assert;
 import org.apache.deltaspike.cdise.api.CdiContainer;
 import org.apache.deltaspike.cdise.api.CdiContainerLoader;
 import org.apache.deltaspike.cdise.api.ContextControl;
@@ -718,7 +719,16 @@ public class CdiTestRunner extends BlockJUnit4ClassRunner
             {
                 if (externalContainer instanceof TestAware)
                 {
-                    ((TestAware)externalContainer).setTestMethod(testMethod);
+                    try
+                    {
+                        ((TestAware)externalContainer).setTestMethod(testMethod);
+                    }
+                    catch (Throwable t)
+                    {
+                        //with a correct setup it shouldn't happen
+                        //TODO better handling for invalid constellations
+                        Assert.fail(t.getMessage());
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/pom.xml b/deltaspike/modules/test-control/impl/pom.xml
index 46514b2..dd3ab58 100644
--- a/deltaspike/modules/test-control/impl/pom.xml
+++ b/deltaspike/modules/test-control/impl/pom.xml
@@ -74,6 +74,12 @@
 
         <dependency>
             <groupId>org.apache.myfaces.core</groupId>
+            <artifactId>myfaces-impl-test</artifactId>
+            <scope>provided</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.myfaces.core</groupId>
             <artifactId>myfaces-api</artifactId>
             <scope>provided</scope>
         </dependency>

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerAdapter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerAdapter.java
b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerAdapter.java
new file mode 100644
index 0000000..0ac77fa
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerAdapter.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.testcontrol.impl.jsf;
+
+import org.apache.deltaspike.core.api.config.ConfigResolver;
+import org.apache.deltaspike.testcontrol.spi.ExternalContainer;
+import org.apache.deltaspike.testcontrol.spi.TestAware;
+import org.apache.myfaces.mc.test.core.runner.MyFacesContainer;
+import org.junit.runners.model.TestClass;
+
+import javax.enterprise.context.RequestScoped;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Optional adapter for MyFacesContainer
+ * Requires MyFaces-Core 2.2.x, MyFaces-Test v1.0.6 or higher as well as org.apache.myfaces.core:myfaces-impl-test
+ */
+public class MyFacesContainerAdapter implements TestAware, ExternalContainer
+{
+    private MyFacesContainer mockedMyFacesTestContainer;
+    private Class testClass;
+
+    public void boot()
+    {
+        final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
+
+        this.mockedMyFacesTestContainer = new MyFacesContainer(new TestClass(this.testClass))
+        {
+            @Override
+            protected String getWebappResourcePath()
+            {
+                return ConfigResolver.getPropertyValue("deltaspike.testcontrol.mf.test.webapp_resource_path",
"");
+            }
+
+            @Override
+            protected void setUpServletObjects()
+            {
+                //just needed for MyFaces-Test util v1.0.7
+                //(to bypass issues with the outdated URLClassLoader used by AbstractJsfTestContainer)
+                setCurrentClassLoader(originalClassLoader);
+                super.setUpServletObjects();
+            }
+        };
+
+        this.mockedMyFacesTestContainer.setUp(new Object() /*we don't need the test-instance
here*/);
+    }
+
+    protected void setCurrentClassLoader(ClassLoader originalClassLoader)
+    {
+        Thread.currentThread().setContextClassLoader(originalClassLoader);
+    }
+
+    @Override
+    public void startScope(Class<? extends Annotation> scopeClass)
+    {
+        if (RequestScoped.class.equals(scopeClass))
+        {
+            this.mockedMyFacesTestContainer.startRequest();
+        }
+    }
+
+    @Override
+    public void stopScope(Class<? extends Annotation> scopeClass)
+    {
+        if (RequestScoped.class.equals(scopeClass))
+        {
+            this.mockedMyFacesTestContainer.endRequest();
+        }
+    }
+
+    public void shutdown()
+    {
+        if (this.mockedMyFacesTestContainer == null)
+        {
+            throw new IllegalStateException("During starting MyFaces-Core an exception happened.");
+        }
+        this.mockedMyFacesTestContainer.tearDown();
+    }
+
+    @Override
+    public int getOrdinal()
+    {
+        return 1000; //default in ds
+    }
+
+    @Override
+    public void setTestClass(Class testClass)
+    {
+        this.testClass = testClass;
+    }
+
+    @Override
+    public void setTestMethod(Method method)
+    {
+        //not needed
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerPerTestMethodAdapter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerPerTestMethodAdapter.java
b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerPerTestMethodAdapter.java
new file mode 100644
index 0000000..139bfee
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/jsf/MyFacesContainerPerTestMethodAdapter.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.testcontrol.impl.jsf;
+
+import org.apache.deltaspike.testcontrol.spi.ExternalContainer;
+import org.apache.deltaspike.testcontrol.spi.TestAware;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+/**
+ * Optional adapter for MyFacesContainer which gets started and stopped for every test-method
+ * Requires MyFaces-Core 2.2.x, MyFaces-Test v1.0.6 or higher as well as org.apache.myfaces.core:myfaces-impl-test
+ */
+public class MyFacesContainerPerTestMethodAdapter implements TestAware, ExternalContainer
+{
+    private static ThreadLocal<MyFacesContainerAdapter> myFacesContainerAdapterThreadLocal
=
+            new ThreadLocal<MyFacesContainerAdapter>();
+
+    @Override
+    public void boot()
+    {
+    }
+
+    @Override
+    public void shutdown()
+    {
+    }
+
+    @Override
+    public int getOrdinal()
+    {
+        return 1000; //default in ds
+    }
+
+    @Override
+    public void startScope(Class<? extends Annotation> scopeClass)
+    {
+        myFacesContainerAdapterThreadLocal.get().startScope(scopeClass);
+    }
+
+    @Override
+    public void stopScope(Class<? extends Annotation> scopeClass)
+    {
+        myFacesContainerAdapterThreadLocal.get().stopScope(scopeClass);
+    }
+
+    @Override
+    public void setTestClass(Class testClass)
+    {
+        MyFacesContainerAdapter myFacesContainerAdapter = new MyFacesContainerAdapter();
+        myFacesContainerAdapter.setTestClass(testClass);
+        myFacesContainerAdapterThreadLocal.set(myFacesContainerAdapter);
+    }
+
+    @Override
+    public void setTestMethod(Method testMethod)
+    {
+        if (testMethod != null)
+        {
+            myFacesContainerAdapterThreadLocal.get().boot();
+        }
+        else
+        {
+            myFacesContainerAdapterThreadLocal.get().shutdown();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalMyFacesTestContainerAdapter.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalMyFacesTestContainerAdapter.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalMyFacesTestContainerAdapter.java
new file mode 100644
index 0000000..45c8949
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalMyFacesTestContainerAdapter.java
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.testcontrol;
+
+import org.apache.deltaspike.test.testcontrol.uc005.MockedJsfContainerTest;
+import org.apache.deltaspike.test.testcontrol.uc006.SkipExternalContainerTest;
+import org.apache.deltaspike.test.testcontrol.uc009.JsfContainerTest;
+import org.apache.deltaspike.test.testcontrol.uc010.JsfContainerPerTestMethodTest;
+import org.apache.deltaspike.testcontrol.impl.jsf.MockedJsf2TestContainer;
+import org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerAdapter;
+import org.apache.deltaspike.testcontrol.impl.jsf.MyFacesContainerPerTestMethodAdapter;
+import org.apache.deltaspike.testcontrol.spi.ExternalContainer;
+import org.apache.deltaspike.testcontrol.spi.TestAware;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+public class InternalMyFacesTestContainerAdapter implements TestAware, ExternalContainer
+{
+    private ExternalContainer wrapped;
+
+    @Override
+    public void boot()
+    {
+        wrapped.boot();
+    }
+
+    @Override
+    public void shutdown()
+    {
+        wrapped.shutdown();
+    }
+
+    @Override
+    public int getOrdinal()
+    {
+        return wrapped.getOrdinal();
+    }
+
+    @Override
+    public void startScope(Class<? extends Annotation> scopeClass)
+    {
+        wrapped.startScope(scopeClass);
+    }
+
+    @Override
+    public void stopScope(Class<? extends Annotation> scopeClass)
+    {
+        wrapped.stopScope(scopeClass);
+    }
+
+    @Override
+    public void setTestClass(Class testClass)
+    {
+        if (MockedJsfContainerTest.class.equals(testClass) ||
+            SkipExternalContainerTest.class.equals(testClass))
+        {
+            this.wrapped = new MockedJsf2TestContainer();
+        }
+        else if (JsfContainerTest.class.equals(testClass))
+        {
+            this.wrapped = new MyFacesContainerAdapter();
+            ((TestAware)this.wrapped).setTestClass(testClass);
+        }
+        else if (JsfContainerPerTestMethodTest.class.equals(testClass))
+        {
+            this.wrapped = new MyFacesContainerPerTestMethodAdapter();
+            ((TestAware)this.wrapped).setTestClass(testClass);
+        }
+        else
+        {
+            this.wrapped = new ExternalContainer()
+            {
+                @Override
+                public void boot()
+                {
+                }
+
+                @Override
+                public void shutdown()
+                {
+                }
+
+                @Override
+                public int getOrdinal()
+                {
+                    return 0;
+                }
+
+                @Override
+                public void startScope(Class<? extends Annotation> scopeClass)
+                {
+                }
+
+                @Override
+                public void stopScope(Class<? extends Annotation> scopeClass)
+                {
+                }
+            };
+        }
+    }
+
+    @Override
+    public void setTestMethod(Method testMethod)
+    {
+        if (this.wrapped instanceof TestAware)
+        {
+            ((TestAware)this.wrapped).setTestMethod(testMethod);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/JsfContainerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/JsfContainerTest.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/JsfContainerTest.java
deleted file mode 100644
index caebfa7..0000000
--- a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/JsfContainerTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.deltaspike.test.testcontrol.uc005;
-
-import org.apache.deltaspike.test.category.SeCategory;
-import org.apache.deltaspike.test.testcontrol.shared.RequestScopedBean;
-import org.apache.deltaspike.test.testcontrol.shared.SessionScopedBean;
-import org.apache.deltaspike.testcontrol.api.TestControl;
-import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.render.RenderKitFactory;
-import javax.inject.Inject;
-
-//Usually NOT needed! Currently only needed due to our arquillian-setup
-@Category(SeCategory.class)
-
-
-
-@RunWith(CdiTestRunner.class)
-@TestControl(startExternalContainers = true)
-public class JsfContainerTest
-{
-    @Inject
-    private SessionScopedBean sessionScopedBean;
-
-    @Inject
-    private RequestScopedBean requestScopedBean;
-
-    @Test
-    public void firstTest()
-    {
-        Assert.assertEquals(0, requestScopedBean.getCount());
-        requestScopedBean.increaseCount();
-        Assert.assertEquals(1, requestScopedBean.getCount());
-
-        Assert.assertEquals(0, sessionScopedBean.getCount());
-        sessionScopedBean.increaseCount();
-        Assert.assertEquals(1, sessionScopedBean.getCount());
-
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
-        Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());
-
-        UIViewRoot uiViewRoot = new UIViewRoot();
-        uiViewRoot.setViewId("/test1.xhtml");
-        uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
-        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
-        Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());
-
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());
-
-        Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
-        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test",
"1");
-        Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
-    }
-
-    @Test
-    public void secondTest()
-    {
-        Assert.assertEquals(0, requestScopedBean.getCount());
-        requestScopedBean.increaseCount();
-        Assert.assertEquals(1, requestScopedBean.getCount());
-
-        Assert.assertEquals(0, sessionScopedBean.getCount());
-        sessionScopedBean.increaseCount();
-        Assert.assertEquals(1, sessionScopedBean.getCount());
-
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
-        Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());
-
-        UIViewRoot uiViewRoot = new UIViewRoot();
-        uiViewRoot.setViewId("/test2.xhtml");
-        uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
-        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
-        Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());
-
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
-        Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());
-
-        Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
-        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test",
"2");
-        Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
-    }
-}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/MockedJsfContainerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/MockedJsfContainerTest.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/MockedJsfContainerTest.java
new file mode 100644
index 0000000..a3e9042
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc005/MockedJsfContainerTest.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.testcontrol.uc005;
+
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.shared.RequestScopedBean;
+import org.apache.deltaspike.test.testcontrol.shared.SessionScopedBean;
+import org.apache.deltaspike.testcontrol.api.TestControl;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKitFactory;
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+
+
+@RunWith(CdiTestRunner.class)
+@TestControl(startExternalContainers = true)
+public class MockedJsfContainerTest
+{
+    @Inject
+    private SessionScopedBean sessionScopedBean;
+
+    @Inject
+    private RequestScopedBean requestScopedBean;
+
+    @Test
+    public void firstTest()
+    {
+        Assert.assertEquals(0, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(1, requestScopedBean.getCount());
+
+        Assert.assertEquals(0, sessionScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(1, sessionScopedBean.getCount());
+
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
+        Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        UIViewRoot uiViewRoot = new UIViewRoot();
+        uiViewRoot.setViewId("/test1.xhtml");
+        uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+        Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());
+
+        Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test",
"1");
+        Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+    }
+
+    @Test
+    public void secondTest()
+    {
+        Assert.assertEquals(0, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(1, requestScopedBean.getCount());
+
+        Assert.assertEquals(0, sessionScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(1, sessionScopedBean.getCount());
+
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
+        Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        UIViewRoot uiViewRoot = new UIViewRoot();
+        uiViewRoot.setViewId("/test2.xhtml");
+        uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+        Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());
+
+        Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test",
"2");
+        Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc009/JsfContainerTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc009/JsfContainerTest.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc009/JsfContainerTest.java
new file mode 100644
index 0000000..2e9eac2
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc009/JsfContainerTest.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.testcontrol.uc009;
+
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.testcontrol.shared.RequestScopedBean;
+import org.apache.deltaspike.test.testcontrol.shared.SessionScopedBean;
+import org.apache.deltaspike.testcontrol.api.TestControl;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
+import javax.faces.render.RenderKitFactory;
+import javax.inject.Inject;
+import java.util.Map;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+
+
+@RunWith(CdiTestRunner.class)
+@TestControl(startExternalContainers = true)
+public class JsfContainerTest
+{
+    private Integer identityHashCode;
+
+    @Inject
+    private SessionScopedBean sessionScopedBean;
+
+    @Inject
+    private RequestScopedBean requestScopedBean;
+
+    @Test
+    public void firstTest()
+    {
+        Assert.assertEquals(0, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(1, requestScopedBean.getCount());
+
+        Assert.assertEquals(0, sessionScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(1, sessionScopedBean.getCount());
+
+        UIViewRoot uiViewRoot = new UIViewRoot();
+        uiViewRoot.setViewId("/viewId");
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
+        Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        uiViewRoot.setViewId("/test1.xhtml");
+        uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+        Assert.assertEquals("/test1.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());
+
+        Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test",
"1");
+        Assert.assertEquals("1", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+
+        Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
+        if (identityHashCode == null)
+        {
+            identityHashCode = System.identityHashCode(applicationMap);
+        }
+        else
+        {
+            Assert.assertSame(identityHashCode, System.identityHashCode(applicationMap));
+        }
+    }
+
+    @Test
+    public void secondTest()
+    {
+        Assert.assertEquals(0, requestScopedBean.getCount());
+        requestScopedBean.increaseCount();
+        Assert.assertEquals(1, requestScopedBean.getCount());
+
+        Assert.assertEquals(0, sessionScopedBean.getCount());
+        sessionScopedBean.increaseCount();
+        Assert.assertEquals(1, sessionScopedBean.getCount());
+
+        UIViewRoot uiViewRoot = new UIViewRoot();
+        uiViewRoot.setViewId("/viewId");
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getViewRoot());
+        Assert.assertEquals("/viewId", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        uiViewRoot.setViewId("/test2.xhtml");
+        uiViewRoot.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+
+        FacesContext.getCurrentInstance().setViewRoot(uiViewRoot);
+        Assert.assertEquals("/test2.xhtml", FacesContext.getCurrentInstance().getViewRoot().getViewId());
+
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExternalContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getApplication());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getELContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getPartialViewContext());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getRenderKit());
+        Assert.assertNotNull(FacesContext.getCurrentInstance().getExceptionHandler());
+
+        Assert.assertNull(FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+        FacesContext.getCurrentInstance().getExternalContext().getRequestMap().put("test",
"2");
+        Assert.assertEquals("2", FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("test"));
+
+        Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
+        if (identityHashCode == null)
+        {
+            identityHashCode = System.identityHashCode(applicationMap);
+        }
+        else
+        {
+            Assert.assertSame(identityHashCode, System.identityHashCode(applicationMap));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc010/JsfContainerPerTestMethodTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc010/JsfContainerPerTestMethodTest.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc010/JsfContainerPerTestMethodTest.java
new file mode 100644
index 0000000..c3522ab
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc010/JsfContainerPerTestMethodTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.deltaspike.test.testcontrol.uc010;
+
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.faces.context.FacesContext;
+import java.util.Map;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+
+
+@RunWith(CdiTestRunner.class)
+public class JsfContainerPerTestMethodTest
+{
+    private Integer identityHashCode;
+
+    @Test
+    public void firstTest()
+    {
+        Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
+        if (identityHashCode == null)
+        {
+            identityHashCode = System.identityHashCode(applicationMap);
+        }
+        else
+        {
+            Assert.assertNotSame(identityHashCode, System.identityHashCode(applicationMap));
+        }
+    }
+
+    @Test
+    public void secondTest()
+    {
+        Map applicationMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
+        if (identityHashCode == null)
+        {
+            identityHashCode = System.identityHashCode(applicationMap);
+        }
+        else
+        {
+            Assert.assertNotSame(identityHashCode, System.identityHashCode(applicationMap));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
index 5aff81b..0987e21 100644
--- a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
+++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol.spi.ExternalContainer
@@ -15,4 +15,4 @@
 # specific language governing permissions and limitations
 # under the License.
 
-org.apache.deltaspike.testcontrol.impl.jsf.MockedJsf2TestContainer
\ No newline at end of file
+org.apache.deltaspike.test.testcontrol.InternalMyFacesTestContainerAdapter
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/ce629272/deltaspike/parent/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/parent/pom.xml b/deltaspike/parent/pom.xml
index 34730b6..1754f7d 100644
--- a/deltaspike/parent/pom.xml
+++ b/deltaspike/parent/pom.xml
@@ -58,7 +58,7 @@
 
         <!-- JSF-2.0 implementations-->
         <myfaces2.version>2.0.14</myfaces2.version>
-        <myfaces22.version>2.2.0</myfaces22.version>
+        <myfaces22.version>2.2.3</myfaces22.version>
         <myfaces2.version.current>2.1.8</myfaces2.version.current>
         <mojarra2.version>2.0.3-b03</mojarra2.version>
 
@@ -641,14 +641,21 @@
             <dependency>
                 <groupId>org.apache.myfaces.core</groupId>
                 <artifactId>myfaces-api</artifactId>
-                <version>${myfaces2.version}</version>
+                <version>${myfaces22.version}</version>
                 <scope>provided</scope>
             </dependency>
 
             <dependency>
                 <groupId>org.apache.myfaces.core</groupId>
                 <artifactId>myfaces-impl</artifactId>
-                <version>${myfaces2.version}</version>
+                <version>${myfaces22.version}</version>
+                <scope>provided</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.myfaces.core</groupId>
+                <artifactId>myfaces-impl-test</artifactId>
+                <version>${myfaces22.version}</version>
                 <scope>provided</scope>
             </dependency>
 


Mime
View raw message