myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jak...@apache.org
Subject svn commit: r1004803 - in /myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test: java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/ resources/sc...
Date Tue, 05 Oct 2010 20:13:24 GMT
Author: jakobk
Date: Tue Oct  5 20:13:23 2010
New Revision: 1004803

URL: http://svn.apache.org/viewvc?rev=1004803&view=rev
Log:
tests for EXTCDI-67 and EXTCDI-71

Added:
    myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingDeactivatedTest.java
      - copied, changed from r1004584, myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingTest.java
    myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/
    myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/ScopeMappingDeactivator.java
    myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/deactivated-web.xml

Copied: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingDeactivatedTest.java
(from r1004584, myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingTest.java)
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingDeactivatedTest.java?p2=myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingDeactivatedTest.java&p1=myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingTest.java&r1=1004584&r2=1004803&rev=1004803&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingTest.java
(original)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/ScopeMappingDeactivatedTest.java
Tue Oct  5 20:13:23 2010
@@ -23,6 +23,7 @@ import org.apache.myfaces.extensions.cdi
 import org.apache.myfaces.extensions.cdi.test.webapp.scopemapping.bean.JsfRequestScopedBean;
 import org.apache.myfaces.extensions.cdi.test.webapp.scopemapping.bean.JsfSessionScopedBean;
 import org.apache.myfaces.extensions.cdi.test.webapp.scopemapping.bean.JsfViewScopedBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.scopemapping.deactivator.ScopeMappingDeactivator;
 import org.apache.myfaces.test.webapp.api.annotation.BeansXml;
 import org.apache.myfaces.test.webapp.api.annotation.PageBean;
 import org.apache.myfaces.test.webapp.api.annotation.Tester;
@@ -43,13 +44,14 @@ import javax.faces.event.PhaseId;
               @PageBean(clazz = JsfSessionScopedBean.class),
               @PageBean(clazz = JsfRequestScopedBean.class),
               @PageBean(clazz = JsfViewScopedBean.class),
-              @PageBean(clazz = CdiBean.class)
+              @PageBean(clazz = CdiBean.class),
+              @PageBean(clazz = ScopeMappingDeactivator.class)
       }
 )
 
 @BeansXml
 
-@WebXml("web.xml")
+@WebXml("scopemapping/deactivated-web.xml")
 
 @WebappResource.List
 ({
@@ -79,18 +81,20 @@ import javax.faces.event.PhaseId;
 @RunWith(WebappTestRunner.class)
 
 /**
- * Test cases for EXTCDI-67 jsf2 scopes should be mapped to cdi scopes automatically
+ * Test cases for the deactivation of EXTCDI-67 jsf2 scopes should be mapped
+ * to cdi scopes automatically.
+ * If this feature is deactivated, it should not map the scopes!
  *
  * @author Jakob Korherr
  */
-public class ScopeMappingTest
+public class ScopeMappingDeactivatedTest
 {
 
     @Tester
     private static WebappTester tester;
 
     @Test
-    public void scopemapping_ApplicationScope() throws Exception
+    public void scopemapping_deactivated_ApplicationScope() throws Exception
     {
         tester.assertThat("#{applicationBean.input}").is(JsfApplicationScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
         tester.assertThat("#{cdiBean.jsfApplicationScopedBean.input}").is(JsfApplicationScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
@@ -99,11 +103,11 @@ public class ScopeMappingTest
         tester.click("testForm:navigateToTest2");
 
         tester.assertThat("#{applicationBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
-        tester.assertThat("#{cdiBean.jsfApplicationScopedBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
+        tester.assertThat("#{cdiBean.jsfApplicationScopedBean.input}").is(JsfApplicationScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
     }
 
     @Test
-    public void scopemapping_SessionScope() throws Exception
+    public void scopemapping_deactivated_SessionScope() throws Exception
     {
         tester.assertThat("#{sessionBean.input}").is(JsfSessionScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
         tester.assertThat("#{cdiBean.jsfSessionScopedBean.input}").is(JsfSessionScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
@@ -112,11 +116,11 @@ public class ScopeMappingTest
         tester.click("testForm:navigateToTest2");
 
         tester.assertThat("#{sessionBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
-        tester.assertThat("#{cdiBean.jsfSessionScopedBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
+        tester.assertThat("#{cdiBean.jsfSessionScopedBean.input}").is(JsfSessionScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
     }
 
     @Test
-    public void scopemapping_RequestScope() throws Exception
+    public void scopemapping_deactivated_RequestScope() throws Exception
     {
         tester.assertThat("#{requestBean.input}").is(JsfRequestScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
         tester.assertThat("#{cdiBean.jsfRequestScopedBean.input}").is(JsfRequestScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
@@ -125,7 +129,7 @@ public class ScopeMappingTest
         tester.click("testForm:navigateToTest2");
 
         tester.assertThat("#{requestBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
-        tester.assertThat("#{cdiBean.jsfRequestScopedBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
+        tester.assertThat("#{cdiBean.jsfRequestScopedBean.input}").is(JsfRequestScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
 
         tester.click("test2Form:emptyCommand");
 
@@ -134,7 +138,7 @@ public class ScopeMappingTest
     }
 
     @Test
-    public void scopemapping_ViewScope() throws Exception
+    public void scopemapping_deactivated_ViewScope() throws Exception
     {
         tester.assertThat("#{viewBean.input}").is(JsfViewScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
         tester.assertThat("#{cdiBean.jsfViewScopedBean.input}").is(JsfViewScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
@@ -143,7 +147,7 @@ public class ScopeMappingTest
         tester.click("testForm:emptyCommand");
 
         tester.assertThat("#{viewBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
-        tester.assertThat("#{cdiBean.jsfViewScopedBean.input}").is("value1").after(PhaseId.RENDER_RESPONSE);
+        tester.assertThat("#{cdiBean.jsfViewScopedBean.input}").is(JsfViewScopedBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
 
         tester.click("testForm:navigateToTest2");
 

Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/ScopeMappingDeactivator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/ScopeMappingDeactivator.java?rev=1004803&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/ScopeMappingDeactivator.java
(added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/scopemapping/deactivator/ScopeMappingDeactivator.java
Tue Oct  5 20:13:23 2010
@@ -0,0 +1,52 @@
+/*
+ * 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.myfaces.extensions.cdi.test.webapp.scopemapping.deactivator;
+
+import org.apache.myfaces.extensions.cdi.core.api.AbstractClassDeactivator;
+import org.apache.myfaces.extensions.cdi.core.api.util.ClassUtils;
+
+/**
+ * Deactivates the MappedJsf2ScopeExtension.
+ *
+ * This ClassDeactivator is set via env-entry in the related web.xml file.
+ *
+ * @author Jakob Korherr
+ */
+public class ScopeMappingDeactivator extends AbstractClassDeactivator
+{
+
+    @Override
+    protected void deactivateClasses()
+    {
+        addDeactivatedClass(_getScopeMappingExtensionClass());
+    }
+
+    private Class<?> _getScopeMappingExtensionClass()
+    {
+        try
+        {
+            return ClassUtils.loadClassForName("org.apache.myfaces.extensions.cdi.jsf2.impl.scope.mapped.MappedJsf2ScopeExtension");
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new RuntimeException("Could not find MappedJsf2ScopeExtension in classpath",
e);
+        }
+    }
+
+}

Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/deactivated-web.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/deactivated-web.xml?rev=1004803&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/deactivated-web.xml
(added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/deactivated-web.xml
Tue Oct  5 20:13:23 2010
@@ -0,0 +1,70 @@
+<?xml version = '1.0' encoding = 'ISO-8859-1'?>
+<!--
+    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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
+         version="2.5">
+
+    <env-entry>
+        <env-entry-name>myfaces-codi/ClassDeactivator</env-entry-name>
+        <env-entry-type>java.lang.String</env-entry-type>
+        <env-entry-value>org.apache.myfaces.extensions.cdi.test.webapp.scopemapping.deactivator.ScopeMappingDeactivator</env-entry-value>
+    </env-entry>
+
+    <context-param>
+        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+        <param-value>.xhtml</param-value>
+    </context-param>
+
+    <servlet>
+        <servlet-name>Faces Servlet</servlet-name>
+        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+        <load-on-startup>1</load-on-startup>
+    </servlet>
+
+    <servlet>
+       <servlet-name>ServletTestRunner</servlet-name>
+       <servlet-class>org.apache.myfaces.test.webapp.api.runner.WebappServletTestRunner</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>Faces Servlet</servlet-name>
+        <url-pattern>*.xhtml</url-pattern>
+    </servlet-mapping>
+
+    <servlet-mapping>
+       <servlet-name>ServletTestRunner</servlet-name>
+       <url-pattern>/ArquillianServletRunner</url-pattern>
+    </servlet-mapping>
+
+    <listener>
+        <listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
+    </listener>
+
+    <listener>
+        <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
+    </listener>
+
+    <context-param>
+        <param-name>javax.faces.PROJECT_STAGE</param-name>
+        <param-value>Production</param-value>
+    </context-param>
+
+</web-app>



Mime
View raw message