You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ja...@apache.org on 2010/10/12 00:03:55 UTC
svn commit: r1021532 [1/2] - in
/myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test:
java/org/apache/myfaces/extensions/cdi/test/webapp/events/
java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/
resources/events/ resourc...
Author: jakobk
Date: Mon Oct 11 22:03:54 2010
New Revision: 1021532
URL: http://svn.apache.org/viewvc?rev=1021532&view=rev
Log:
EXTCDI-63 optional bean, conversation and window events (test-cases)
Added:
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventDeactivatedTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventDeactivatedTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventDeactivatedTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventDeactivatedTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventDeactivatedTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventTest.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/ConversationBean.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/EventsBean.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/ViewAccessBean.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/WindowBean.java
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/access-bean-event-enabled-web.xml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/access-bean-event-test1.xhtml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/conversation-events-enabled-web.xml
- copied, changed from r1006221, myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/web.xml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/conversation-events-test1.xhtml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/conversation-events-test2.xhtml
- copied, changed from r1006221, myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/test1.xhtml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/scope-bean-event-test1.xhtml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/scope-bean-event-test2.xhtml
- copied, changed from r1006221, myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/test2.xhtml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/scopebeanevent-enabled-web.xml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/unscopebeanevent-enabled-web.xml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/windowcontext-events-enabled-web.xml
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/events/windowcontext-events-test1.xhtml
Modified:
myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/resources/scopemapping/test2.xhtml
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventDeactivatedTest.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/events/AccessBeanEventDeactivatedTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventDeactivatedTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventDeactivatedTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,165 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ViewAccessBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.WindowBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/access-bean-event-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = ViewAccessBean.class),
+ @PageBean(clazz = WindowBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("web.xml") // use normal web.xml --> events are deactivated
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI AccessBeanEvent, if it is deactivated (default).
+ *
+ * @author Jakob Korherr
+ */
+public class AccessBeanEventDeactivatedTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void accessBeanEvent_ConversationScoped_Deactivated() throws Exception
+ {
+ // do not reference conversationBean
+
+ // conversationBean must not have been accessed yet
+ tester.assertThat("#{eventsBean.conversationBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // conversationBean must have been accessed once
+ tester.assertThat("#{eventsBean.conversationBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // conversationBean must have been accessed three times
+ tester.assertThat("#{eventsBean.conversationBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void accessBeanEvent_WindowScoped_Deactivated() throws Exception
+ {
+ // do not reference windowBean
+
+ // windowBean must not have been accessed yet
+ tester.assertThat("#{eventsBean.windowBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // windowBean must have been accessed once
+ tester.assertThat("#{eventsBean.windowBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // windowBean must have been accessed three times
+ tester.assertThat("#{eventsBean.windowBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void accessBeanEvent_ViewAccessScoped_Deactivated() throws Exception
+ {
+ // do not reference viewAccessBean
+
+ // viewAccessBean must not have been accessed yet
+ tester.assertThat("#{eventsBean.viewaccessBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // viewAccessBean must have been accessed once
+ tester.assertThat("#{eventsBean.viewaccessBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // viewAccessBean must have been accessed three times
+ tester.assertThat("#{eventsBean.viewaccessBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventTest.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/events/AccessBeanEventTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/AccessBeanEventTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,165 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ViewAccessBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.WindowBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/access-bean-event-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = ViewAccessBean.class),
+ @PageBean(clazz = WindowBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("events/access-bean-event-enabled-web.xml")
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI AccessBeanEvent.
+ *
+ * @author Jakob Korherr
+ */
+public class AccessBeanEventTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void accessBeanEvent_ConversationScoped() throws Exception
+ {
+ // do not reference conversationBean
+
+ // conversationBean must not have been accessed yet
+ tester.assertThat("#{eventsBean.conversationBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // conversationBean must have been accessed once
+ tester.assertThat("#{eventsBean.conversationBeanAccessed}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // conversationBean must have been accessed three times
+ tester.assertThat("#{eventsBean.conversationBeanAccessed}").is(3).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void accessBeanEvent_WindowScoped() throws Exception
+ {
+ // do not reference windowBean
+
+ // windowBean must not have been accessed yet
+ tester.assertThat("#{eventsBean.windowBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // windowBean must have been accessed once
+ tester.assertThat("#{eventsBean.windowBeanAccessed}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // windowBean must have been accessed three times
+ tester.assertThat("#{eventsBean.windowBeanAccessed}").is(3).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void accessBeanEvent_ViewAccessScoped() throws Exception
+ {
+ // do not reference viewAccessBean
+
+ // viewAccessBean must not have been accessed yet
+ tester.assertThat("#{eventsBean.viewaccessBeanAccessed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // viewAccessBean must have been accessed once
+ tester.assertThat("#{eventsBean.viewaccessBeanAccessed}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).after(PhaseId.INVOKE_APPLICATION);
+
+ // viewAccessBean must have been accessed three times
+ tester.assertThat("#{eventsBean.viewaccessBeanAccessed}").is(3).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventDeactivatedTest.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/events/ConversationEventDeactivatedTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventDeactivatedTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventDeactivatedTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,168 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.annotation.WebappResource;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/conversation-events-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("web.xml") // use normal web.xml --> events are deactivated
+
+@WebappResource.List
+({
+ @WebappResource("events/conversation-events-test2.xhtml")
+})
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI ConversationEvents, if they are deactivated.
+ *
+ * @author Jakob Korherr
+ */
+public class ConversationEventDeactivatedTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ //TODO kommentare passen nimma!!
+
+ @Test
+ public void startConversationEvent_Implicit_Start_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation-events-test2.xhtml references conversationBean,
+ // thus the conversation must have been started
+ // event must not be published, because it is deactivated by default
+ tester.assertThat("#{eventsBean.conversationStarted}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.assertThat("#{eventsBean.startedConversation}").is(null).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void closeConversationEvent_Injected_Conversation_Close_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation started, but didn't close yet
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:conversationBean_closeConversation");
+
+ // value must be in the conversation bean and the conversation must still be open
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation must be closed now
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+
+ // event must not have been fired
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void closeConversationEvent_WindowContext_Close_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation started, but didn't close yet
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:conversationBean_closeWindowContext");
+
+ // value must be in the conversation bean and the conversation must still be open
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation must be closed now
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+
+ // event must not have been fired
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void restartConversationEvent_Injected_Conversation_Restart_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation started, but didn't restart yet
+ tester.assertThat("#{eventsBean.conversationRestarted}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:conversationBean_restartConversation");
+
+ // value must be in the conversation bean and the conversation must still be open
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+ tester.assertThat("#{eventsBean.conversationRestarted}").is(false).after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation must be restarted now
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+
+ // event must not have been fired
+ tester.assertThat("#{eventsBean.conversationRestarted}").is(false).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventTest.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/events/ConversationEventTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ConversationEventTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,165 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.annotation.WebappResource;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/conversation-events-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("events/conversation-events-enabled-web.xml")
+
+@WebappResource.List
+({
+ @WebappResource("events/conversation-events-test2.xhtml")
+})
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI ConversationEvents.
+ *
+ * @author Jakob Korherr
+ */
+public class ConversationEventTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void startConversationEvent_Implicit_Start() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation-events-test2.xhtml references conversationBean, thus the conversation must have been started
+ tester.assertThat("#{eventsBean.conversationStarted}").is(true).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:eventsBean_closeStartedConversationAndNavigateToTest1");
+
+ // value must be in the conversation bean
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation instance from the event must be able to close the conversation
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void closeConversationEvent_Injected_Conversation_Close() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation started, but didn't close yet
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:conversationBean_closeConversation");
+
+ // value must be in the conversation bean and the conversation must still be open
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation must be closed now
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.conversationClosed}").is(true).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void closeConversationEvent_WindowContext_Close() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation started, but didn't close yet
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:conversationBean_closeWindowContext");
+
+ // value must be in the conversation bean and the conversation must still be open
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+ tester.assertThat("#{eventsBean.conversationClosed}").is(false).after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation must be closed now
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.conversationClosed}").is(true).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void restartConversationEvent_Injected_Conversation_Restart() throws Exception
+ {
+ // reset EventsBean and navigate to conversation-events-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartConversationTest");
+
+ // conversation started, but didn't restart yet
+ tester.assertThat("#{eventsBean.conversationRestarted}").is(false).after(PhaseId.RENDER_RESPONSE);
+
+ tester.input("value").into("testForm:conversationBean_input");
+ tester.click("testForm:conversationBean_restartConversation");
+
+ // value must be in the conversation bean and the conversation must still be open
+ tester.assertThat("#{conversationBean.input}").is("value").after(PhaseId.UPDATE_MODEL_VALUES);
+ tester.assertThat("#{eventsBean.conversationRestarted}").is(false).after(PhaseId.UPDATE_MODEL_VALUES);
+
+ // conversation must be restarted now
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.conversationRestarted}").is(true).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventDeactivatedTest.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/events/ScopeBeanEventDeactivatedTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventDeactivatedTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventDeactivatedTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,153 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ViewAccessBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.WindowBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.annotation.WebappResource;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/scope-bean-event-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = ViewAccessBean.class),
+ @PageBean(clazz = WindowBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("web.xml") // use normal web.xml --> events are deactivated
+
+@WebappResource.List
+({
+ @WebappResource("events/scope-bean-event-test2.xhtml")
+})
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI ScopeBeanEvent, if it is deactivated (default).
+ *
+ * @author Jakob Korherr
+ */
+public class ScopeBeanEventDeactivatedTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void scopeBeanEvent_ConversationScoped_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // conversationBean must have been scoped once
+ tester.assertThat("#{eventsBean.conversationBeanScoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close conversation
+ tester.click("test2Form:conversationBean_closeConversation");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // conversationBean must have been scoped again
+ tester.assertThat("#{eventsBean.conversationBeanScoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void scopeBeanEvent_ViewAccessScoped_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // viewaccessBean must have been scoped once
+ tester.assertThat("#{eventsBean.viewaccessBeanScoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close windowContext
+ tester.click("test2Form:viewAccessBean_closeWindowContext");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // viewaccessBean must have been scoped again
+ tester.assertThat("#{eventsBean.viewaccessBeanScoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void scopeBeanEvent_WindowScoped_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // windowBean must have been scoped once
+ tester.assertThat("#{eventsBean.windowBeanScoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close window context
+ tester.click("test2Form:windowBean_closeWindowContext");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // windowBean must have been scoped again
+ tester.assertThat("#{eventsBean.windowBeanScoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventTest.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/events/ScopeBeanEventTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/ScopeBeanEventTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,153 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ViewAccessBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.WindowBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.annotation.WebappResource;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/scope-bean-event-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = ViewAccessBean.class),
+ @PageBean(clazz = WindowBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("events/scopebeanevent-enabled-web.xml")
+
+@WebappResource.List
+({
+ @WebappResource("events/scope-bean-event-test2.xhtml")
+})
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI ScopeBeanEvent.
+ *
+ * @author Jakob Korherr
+ */
+public class ScopeBeanEventTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void scopeBeanEvent_ConversationScoped() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // conversationBean must have been scoped once
+ tester.assertThat("#{eventsBean.conversationBeanScoped}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // close conversation
+ tester.click("test2Form:conversationBean_closeConversation");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // conversationBean must have been scoped again
+ tester.assertThat("#{eventsBean.conversationBeanScoped}").is(2).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void scopeBeanEvent_ViewAccessScoped() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // viewaccessBean must have been scoped once
+ tester.assertThat("#{eventsBean.viewaccessBeanScoped}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // close windowContext
+ tester.click("test2Form:viewAccessBean_closeWindowContext");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // viewaccessBean must have been scoped again
+ tester.assertThat("#{eventsBean.viewaccessBeanScoped}").is(2).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void scopeBeanEvent_WindowScoped() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // windowBean must have been scoped once
+ tester.assertThat("#{eventsBean.windowBeanScoped}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // close window context
+ tester.click("test2Form:windowBean_closeWindowContext");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // windowBean must have been scoped again
+ tester.assertThat("#{eventsBean.windowBeanScoped}").is(2).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventDeactivatedTest.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/events/UnscopeBeanEventDeactivatedTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventDeactivatedTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventDeactivatedTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,144 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ViewAccessBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.WindowBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.annotation.WebappResource;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/scope-bean-event-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = ViewAccessBean.class),
+ @PageBean(clazz = WindowBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("web.xml") // use normal web.xml --> events are deactivated
+
+@WebappResource.List
+({
+ @WebappResource("events/scope-bean-event-test2.xhtml")
+})
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI UnscopeBeanEvent, if it is deactivated (default).
+ *
+ * @author Jakob Korherr
+ */
+public class UnscopeBeanEventDeactivatedTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void unscopeBeanEvent_ConversationScoped_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // conversationBean must not have been unscoped yet
+ tester.assertThat("#{eventsBean.conversationBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close conversation
+ tester.click("test2Form:conversationBean_closeConversation");
+
+ // conversationBean must have been unscoped once
+ tester.assertThat("#{eventsBean.conversationBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void unscopeBeanEvent_WindowScoped_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // windowBean must not have been unscoped yet
+ tester.assertThat("#{eventsBean.windowBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close WindowContext
+ tester.click("test2Form:windowBean_closeWindowContext");
+
+ // windowBean must have been unscoped once
+ tester.assertThat("#{eventsBean.windowBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void unscopeBeanEvent_ViewAccessScoped_Deactivated() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // viewAccessBean must not have been unscoped yet
+ tester.assertThat("#{eventsBean.viewaccessBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close WindowContext
+ tester.click("test2Form:viewAccessBean_closeWindowContext");
+
+ // viewAccessBean must have been unscoped once
+ tester.assertThat("#{eventsBean.viewaccessBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventTest.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/events/UnscopeBeanEventTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/UnscopeBeanEventTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,144 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ViewAccessBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.WindowBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.annotation.WebappResource;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/scope-bean-event-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = ViewAccessBean.class),
+ @PageBean(clazz = WindowBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("events/unscopebeanevent-enabled-web.xml")
+
+@WebappResource.List
+({
+ @WebappResource("events/scope-bean-event-test2.xhtml")
+})
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI UnscopeBeanEvent.
+ *
+ * @author Jakob Korherr
+ */
+public class UnscopeBeanEventTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void unscopeBeanEvent_ConversationScoped() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference conversationBean
+ tester.assertThat("#{conversationBean.input}").is(ConversationBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // conversationBean must not have been unscoped yet
+ tester.assertThat("#{eventsBean.conversationBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close conversation
+ tester.click("test2Form:conversationBean_closeConversation");
+
+ // conversationBean must have been unscoped once
+ tester.assertThat("#{eventsBean.conversationBeanUnscoped}").is(1).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void unscopeBeanEvent_WindowScoped() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference windowBean
+ tester.assertThat("#{windowBean.input}").is(WindowBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // windowBean must not have been unscoped yet
+ tester.assertThat("#{eventsBean.windowBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close WindowContext
+ tester.click("test2Form:windowBean_closeWindowContext");
+
+ // windowBean must have been unscoped once
+ tester.assertThat("#{eventsBean.windowBeanUnscoped}").is(1).after(PhaseId.RENDER_RESPONSE);
+ }
+
+ @Test
+ public void unscopeBeanEvent_ViewAccessScoped() throws Exception
+ {
+ // reset EventsBean and navigate to scope-bean-event-test2.xhtml
+ tester.click("testForm:eventsBean_resetAndStartScopeBeanTest");
+
+ // manually reference viewAccessBean
+ tester.assertThat("#{viewAccessBean.input}").is(ViewAccessBean.INPUT_DEFAULT_VALUE).before(PhaseId.RENDER_RESPONSE);
+
+ // viewAccessBean must not have been unscoped yet
+ tester.assertThat("#{eventsBean.viewaccessBeanUnscoped}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // close WindowContext
+ tester.click("test2Form:viewAccessBean_closeWindowContext");
+
+ // viewAccessBean must have been unscoped once
+ tester.assertThat("#{eventsBean.viewaccessBeanUnscoped}").is(1).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventDeactivatedTest.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/events/WindowContextEventDeactivatedTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventDeactivatedTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventDeactivatedTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,101 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/windowcontext-events-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("web.xml") // use normal web.xml --> events are deactivated
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI WindowContext Events, if they're deactivated (default).
+ *
+ * @author Jakob Korherr
+ */
+public class WindowContextEventDeactivatedTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void createWindowContextEvent_closeWindowContextEvent_Deactivated() throws Exception
+ {
+ // a WindowContext is created for every request
+ // NOTE that the closing can only be asserted on the next request,
+ // because the WindowContext still needs to be open in RENDER_RESPONSE
+ // after-PhaseListeners.
+
+ tester.assertThat("#{eventsBean.windowContextCreated}").is(0).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.windowContextClosed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ tester.assertThat("#{eventsBean.windowContextCreated}").is(0).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.windowContextClosed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ tester.assertThat("#{eventsBean.windowContextCreated}").is(0).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.windowContextClosed}").is(0).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventTest.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/events/WindowContextEventTest.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventTest.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/WindowContextEventTest.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,101 @@
+/*
+ * 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.events;
+
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.ConversationBean;
+import org.apache.myfaces.extensions.cdi.test.webapp.events.bean.EventsBean;
+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;
+import org.apache.myfaces.test.webapp.api.annotation.View;
+import org.apache.myfaces.test.webapp.api.annotation.WebXml;
+import org.apache.myfaces.test.webapp.api.annotation.WebappDependency;
+import org.apache.myfaces.test.webapp.api.runner.WebappTestRunner;
+import org.apache.myfaces.test.webapp.api.tester.WebappTester;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.faces.event.PhaseId;
+
+@View(id = "events/windowcontext-events-test1.xhtml",
+ pageBeans = {
+ @PageBean(clazz = ConversationBean.class),
+ @PageBean(clazz = EventsBean.class)
+ }
+)
+
+@BeansXml
+
+@WebXml("events/windowcontext-events-enabled-web.xml")
+
+@WebappDependency.List
+({
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.core:myfaces-extcdi-core-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-jsf20-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-api:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.myfaces.extensions.cdi.modules:myfaces-extcdi-message-module-impl:jar:1.0.0-SNAPSHOT"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-impl:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-spi:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-jsf:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-resource:jar:1.0.0-alpha-2"),
+ @WebappDependency("org.apache.openwebbeans:openwebbeans-web:jar:1.0.0-alpha-2"),
+ @WebappDependency("javassist:javassist:jar:3.12.0.GA"),
+ @WebappDependency("net.sf.scannotation:scannotation:jar:1.0.2")
+})
+
+@RunWith(WebappTestRunner.class)
+
+/**
+ * Test cases for the CODI WindowContext Events.
+ *
+ * @author Jakob Korherr
+ */
+public class WindowContextEventTest
+{
+
+ @Tester
+ private static WebappTester tester;
+
+ @Test
+ public void createWindowContextEvent_closeWindowContextEvent() throws Exception
+ {
+ // a WindowContext is created for every request
+ // NOTE that the closing can only be asserted on the next request,
+ // because the WindowContext still needs to be open in RENDER_RESPONSE
+ // after-PhaseListeners.
+
+ tester.assertThat("#{eventsBean.windowContextCreated}").is(1).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.windowContextClosed}").is(0).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ tester.assertThat("#{eventsBean.windowContextCreated}").is(2).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.windowContextClosed}").is(1).after(PhaseId.RENDER_RESPONSE);
+
+ // new request
+ tester.click("testForm:emptyCommand");
+
+ tester.assertThat("#{eventsBean.windowContextCreated}").is(3).after(PhaseId.RENDER_RESPONSE);
+ tester.assertThat("#{eventsBean.windowContextClosed}").is(2).after(PhaseId.RENDER_RESPONSE);
+ }
+
+}
Added: myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/ConversationBean.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/events/bean/ConversationBean.java?rev=1021532&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/ConversationBean.java (added)
+++ myfaces/extensions/cdi/trunk/test-modules/webapp-test-module/src/test/java/org/apache/myfaces/extensions/cdi/test/webapp/events/bean/ConversationBean.java Mon Oct 11 22:03:54 2010
@@ -0,0 +1,99 @@
+/*
+ * 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.events.bean;
+
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.Conversation;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.ConversationScoped;
+import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
+
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.io.Serializable;
+
+/**
+ * @author Jakob Korherr
+ */
+@Named
+@ConversationScoped
+public class ConversationBean implements Serializable
+{
+
+ public static final String INPUT_DEFAULT_VALUE = "no input";
+
+ private String _input;
+
+ @Inject
+ private WindowContext _windowContext;
+
+ @Inject
+ private Conversation _conversation;
+
+ @PostConstruct
+ public void init()
+ {
+ _input = INPUT_DEFAULT_VALUE;
+ }
+
+ public String closeConversationGroup()
+ {
+ _windowContext.closeConversationGroup(ConversationBean.class);
+
+ return null;
+ }
+
+ public String closeWindowContext()
+ {
+ _windowContext.close();
+
+ return null;
+ }
+
+ public String closeConversationsWindowContext()
+ {
+ _windowContext.closeConversations();
+
+ return null;
+ }
+
+ public String closeConversation()
+ {
+ _conversation.close();
+
+ return null;
+ }
+
+ public String restartConversation()
+ {
+ _conversation.restart();
+
+ return null;
+ }
+
+ public String getInput()
+ {
+ return _input;
+ }
+
+ public void setInput(String input)
+ {
+ _input = input;
+ }
+
+}