Author: jharting
Date: 2010-02-19 04:55:53 -0500 (Fri, 19 Feb 2010)
New Revision: 5888
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/AbstractConversationTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/BuiltInConversation.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cloud.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/CloudController.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationStatusServlet.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTestPhaseListener.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cumulus.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/InvalidatingSessionDestroysConversationTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/LongRunningConversationPropagatedByFacesContextTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ManualCidPropagationTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Storm.java
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/builtin.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cloud.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/clouds.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cumulus.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/error.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/faces-config.xml
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/home.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/lightening.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/rain.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/storm.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/thunder.jsf
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml
Removed:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/client/
Log:
CDITCK-109
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/AbstractConversationTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/AbstractConversationTest.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/AbstractConversationTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlElement;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+
+public abstract class AbstractConversationTest extends AbstractJSR299Test
+{
+
+ public static final String CID_REQUEST_PARAMETER_NAME = "cid";
+
+ public static final String CID_HEADER_NAME = "org.jboss.jsr299.tck.cid";
+
+ public static final String LONG_RUNNING_HEADER_NAME =
"org.jboss.jsr299.tck.longRunning";
+
+ protected boolean isCloudDestroyed(WebClient client) throws Exception
+ {
+ Page page = client.getPage(getConversationStatusPath("cloudDestroyed"));
+ return page.getWebResponse().getStatusCode() == 200;
+ }
+
+ protected void resetCloud(WebClient client) throws Exception
+ {
+ client.getPage(getConversationStatusPath("resetCloud"));
+ }
+
+ protected void invalidateSession(WebClient client) throws Exception
+ {
+ client.getPage(getConversationStatusPath("invalidateSession"));
+ }
+
+ protected String getConversationStatusPath(String method)
+ {
+ return super.getContextPath() + "conversation-status?method=" + method;
+ }
+
+ protected String getPath(String viewId)
+ {
+ return getContextPath() + viewId;
+ }
+
+ protected String getPath(String viewId, String cid)
+ {
+ return getContextPath() + viewId + "?" + CID_REQUEST_PARAMETER_NAME +
"=" + cid;
+ }
+
+ protected <T> Set<T> getElements(HtmlElement rootElement, Class<T>
elementClass)
+ {
+ Set<T> result = new HashSet<T>();
+
+ for (HtmlElement element : rootElement.getAllHtmlChildElements())
+ {
+ result.addAll(getElements(element, elementClass));
+ }
+
+ if (elementClass.isInstance(rootElement))
+ {
+ result.add(elementClass.cast(rootElement));
+ }
+ return result;
+
+ }
+
+ protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page,
Class<T> elementClass, String id)
+ {
+
+ Set<T> inputs = getElements(page.getBody(), elementClass);
+ for (T input : inputs)
+ {
+ if (input.getId().contains(id))
+ {
+ return input;
+ }
+ }
+ return null;
+ }
+
+ protected String getCid(Page page)
+ {
+ return
page.getWebResponse().getResponseHeaderValue(AbstractConversationTest.CID_HEADER_NAME);
+ }
+
+ protected Boolean hasRained(Page page)
+ {
+ return
Boolean.valueOf(page.getWebResponse().getResponseHeaderValue(Cloud.RAINED_HEADER_NAME));
+ }
+
+ protected Boolean isLongRunning(Page page)
+ {
+ return
Boolean.valueOf(page.getWebResponse().getResponseHeaderValue(LONG_RUNNING_HEADER_NAME));
+ }
+
+
+}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/BuiltInConversation.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/BuiltInConversation.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/BuiltInConversation.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,78 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@ConversationScoped
+@Named("builtin")
+public class BuiltInConversation implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ @Inject
+ private BeanManager manager;
+ @Inject
+ private Conversation conversation;
+
+ public boolean isScopeCorrect()
+ {
+ return getConversationBean().getScope().equals(RequestScoped.class);
+ }
+
+ public boolean isQualifierCorrect()
+ {
+ for (Annotation qualifier : getConversationBean().getQualifiers())
+ {
+ if (qualifier.annotationType().equals(Default.class))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isNameCorrect()
+ {
+ return
getConversationBean().getName().equals("javax.enterprise.context.conversation");
+ }
+
+ public boolean isDefaultConversationHasNullId()
+ {
+ return conversation.isTransient() && conversation.getId() == null;
+ }
+
+ private Bean<?> getConversationBean()
+ {
+ Set<Bean<?>> beans = manager.getBeans(Conversation.class);
+ if (beans.size() != 1)
+ {
+ throw new RuntimeException("Multiple beans found for Conversation
class.");
+ }
+ return beans.iterator().next();
+ }
+}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,357 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WebXml;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.Page;
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSpan;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+
+/**
+ * @author Nicklas Karlsson
+ * @author Dan Allen
+ */
+@Artifact(addCurrentPackage=false)
+(a)Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class, CloudController.class, Cumulus.class,
BuiltInConversation.class})
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination="home.jspx", source="home.jsf"),
+ @Resource(destination="cloud.jspx", source="cloud.jsf"),
+ @Resource(destination="clouds.jspx", source="clouds.jsf"),
+ @Resource(destination="cumulus.jspx", source="cumulus.jsf"),
+ @Resource(destination="builtin.jspx", source="builtin.jsf"),
+ @Resource(destination="error.jspx", source="error.jsf"),
+ @Resource(destination="storm.jspx", source="storm.jsf"),
+ @Resource(destination="/WEB-INF/faces-config.xml",
source="faces-config.xml"),
+ @Resource(destination="rain.jspx", source="rain.jsf")
+})
+(a)WebXml("web.xml")
+@SpecVersion(spec="cdi", version="20091101")
+public class ClientConversationContextTest extends AbstractConversationTest
+{
+
+ private WebClient client;
+
+
+ @Override
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ client = new WebClient();
+ }
+
+
+ @Test(groups = { "contexts"})
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "hb"),
+ @SpecAssertion(section = "6.7.4", id = "o")
+ })
+ public void testConversationIdSetByContainerIsUnique() throws Exception
+ {
+ HtmlPage storm = client.getPage(getPath("/storm.jsf"));
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "beginConversationButton");
+ storm = beginConversationButton.click();
+
+ String c1 = getCid(storm);
+
+ storm = client.getPage(getPath("/storm.jsf"));
+ beginConversationButton = getFirstMatchingElement(storm, HtmlSubmitInput.class,
"beginConversationButton");
+ storm = beginConversationButton.click();
+
+ String c2 = getCid(storm);
+
+ assert !c1.equals(c2);
+ }
+
+ @Test(groups = { "contexts", "rewrite" })
+ @SpecAssertion(section = "6.7.4", id = "j")
+ // TODO this test doesn't verify that the conversation context itself is
destroyed
+ public void testTransientConversationInstancesDestroyedAtRequestEnd() throws
Exception
+ {
+ resetCloud(client);
+ HtmlPage page = client.getPage(getPath("/cloud.jsf"));
+ assert !isLongRunning(page);
+ assert isCloudDestroyed(client);
+ }
+
+ @Test(groups = { "contexts"})
+ @SpecAssertion(section = "6.7.4", id = "k")
+ public void testLongRunningConversationInstancesNotDestroyedAtRequestEnd() throws
Exception
+ {
+ HtmlPage storm = client.getPage(getPath("/storm.jsf"));
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "beginConversationButton");
+ storm = beginConversationButton.click();
+
+ resetCloud(client);
+
+ client.getPage(getPath("/cloud.jsf", getCid(storm)));
+ assert !isCloudDestroyed(client);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "p")
+ public void testConversationsDontCrossSessionBoundary1() throws Exception
+ {
+ // Load the page
+ HtmlPage rain = client.getPage(getPath("/rain.jsf"));
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(rain,
HtmlSubmitInput.class, "beginConversationButton");
+ rain = beginConversationButton.click();
+ String cid = getCid(rain);
+
+ // Cause rain
+ HtmlSubmitInput rainButton = getFirstMatchingElement(rain, HtmlSubmitInput.class,
"rain");
+ rain = rainButton.click();
+
+ // Re-request the page, inside the conversation and check it has rained
+ rain = client.getPage(getPath("/rain.jsf", cid));
+ assert hasRained(rain);
+
+ // Invalidate the session, invalidate the conversation-scoped cloud
+ invalidateSession(client);
+
+ // Re-request the page, check it hasn't rained
+ rain = client.getPage(getPath("/rain.jsf", cid));
+ assert !hasRained(rain);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "p")
+ public void testConversationsDontCrossSessionBoundary2() throws Exception
+ {
+ // Load the page
+ HtmlPage rain = client.getPage(getPath("/rain.jsf"));
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(rain,
HtmlSubmitInput.class, "beginConversationButton");
+ rain = beginConversationButton.click();
+ String cid = getCid(rain);
+
+ // Cause rain
+ HtmlSubmitInput rainButton = getFirstMatchingElement(rain, HtmlSubmitInput.class,
"rain");
+ rain = rainButton.click();
+
+ // Re-request the page, inside the conversation and check it has rained
+ rain = client.getPage(getPath("/rain.jsf", cid));
+ assert hasRained(rain);
+
+ // Create a new web client and load the page
+ client = new WebClient();
+ rain = client.getPage(getPath("/rain.jsf", cid));
+ assert !hasRained(rain);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "a")
+ public void testConversationActiveDuringNonFacesRequest() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cloud.jsf"));
+ HtmlSpan span = getFirstMatchingElement(page, HtmlSpan.class,
"cloudName");
+ assert span.getTextContent().equals(Cloud.NAME);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "tb")
+ public void
testConversationPropagationToNonExistentConversationLeadsToTransientConversation() throws
Exception
+ {
+ Page page = client.getPage(getPath("/cloud.jsf",
"org.jboss.jsr299"));
+ assert !isLongRunning(page);
+ assert !getCid(page).equals("org.jboss.jsr299");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "f")
+ public void testConversationBeginMakesConversationLongRunning() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationButton");
+ page = beginConversationButton.click();
+ assert isLongRunning(page);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.5", id = "r")
+ public void testBeginAlreadyLongRunningConversationThrowsException() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationButton");
+ page = beginConversationButton.click();
+ assert isLongRunning(page);
+
+ // begin a conversation again and check that IllegalStateException is thrown
+ HtmlSubmitInput beginConversationButton2 = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationAndSwallowException");
+ page = beginConversationButton2.click();
+ assert page.getBody().getTextContent().contains("Hello world!");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "g"),
+ @SpecAssertion(section = "6.7.5", id = "k"),
+ @SpecAssertion(section = "6.7.5", id = "o")
+ })
+ public void testConversationEndMakesConversationTransient() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationButton");
+ page = beginConversationButton.click();
+ assert isLongRunning(page);
+
+ // end a conversation
+ HtmlSubmitInput endConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "endConversationButton");
+ page = endConversationButton.click();
+ assert !isLongRunning(page);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.5", id = "q")
+ public void testEndTransientConversationThrowsException() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // try ending a transient conversation
+ HtmlSubmitInput endConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "endConversationAndSwallowException");
+ page = endConversationButton.click();
+ assert page.getBody().getTextContent().contains("Hello world!");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.5", id = "ib"),
+ @SpecAssertion(section = "6.7.5", id = "iaa")
+ })
+ public void testBeanWithRequestScope() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/builtin.jsf"));
+ assert page.getBody().getTextContent().contains("Correct scope: true");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.5", id = "id")
+ public void testBeanWithDefaultQualifier() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/builtin.jsf"));
+ assert page.getBody().getTextContent().contains("Correct qualifier:
true");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.5", id = "ie")
+ public void testBeanWithNameJavaxEnterpriseContextConversation() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/builtin.jsf"));
+ assert page.getBody().getTextContent().contains("Correct name: true");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.5", id = "l"),
+ @SpecAssertion(section = "6.7.4", id = "e")
+ })
+ public void testTransientConversationHasNullId() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/builtin.jsf"));
+ assert page.getBody().getTextContent().contains("Default conversation has null
id: true");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "ha"),
+ @SpecAssertion(section = "6.7.5", id = "j")
+ })
+ public void testConversationIdMayBeSetByApplication() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationIdentifiedByCustomIdentifier");
+ page = beginConversationButton.click();
+ assert isLongRunning(page);
+ assert getCid(page).equals("humilis");
+ assert page.getBody().getTextContent().contains("Cumulus humilis");
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "hb"),
+ @SpecAssertion(section = "6.7.5", id = "j")
+ })
+ public void testConversationIdMayBeSetByContainer() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationButton");
+ page = beginConversationButton.click();
+ assert isLongRunning(page);
+ assert getCid(page) != null;
+ assert page.getBody().getTextContent().contains("Cumulus congestus");
+ }
+
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.5", id = "m"),
+ @SpecAssertion(section = "6.7.5", id = "n")
+ })
+ public void testSetConversationTimeoutOverride() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation and set a custom timeout
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationAndSetTimeout");
+ page = beginConversationButton.click();
+ assert page.getBody().getTextContent().contains("Cumulonimbus");
+ }
+
+ @Test
+ @SpecAssertion(section = "6.7.5", id = "m")
+ public void testConversationHasDefaultTimeout() throws Exception
+ {
+ HtmlPage page = client.getPage(getPath("/cumulus.jsf"));
+ assert !isLongRunning(page);
+
+ // begin a conversation
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(page,
HtmlSubmitInput.class, "beginConversationButton");
+ page = beginConversationButton.click();
+ assert page.getBody().getTextContent().contains("Stratocumulus");
+ }
+}
\ No newline at end of file
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cloud.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cloud.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cloud.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import java.io.Serializable;
+
+import javax.annotation.PreDestroy;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.Default;
+import javax.inject.Named;
+
+@Named @Default
+@ConversationScoped
+public class Cloud implements Serializable
+{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5765109971012677278L;
+
+ public static final String NAME = Cloud.class.getName() + ".Pete";
+
+ public static final String RAINED_HEADER_NAME = Cloud.class.getName() +
".rained";
+
+ private static boolean destroyed = false;
+
+ private boolean rained;
+
+ @PreDestroy
+ public void destroy()
+ {
+ destroyed = true;
+ }
+
+ public static boolean isDestroyed()
+ {
+ return destroyed;
+ }
+
+ public static void setDestroyed(boolean destroyed)
+ {
+ Cloud.destroyed = destroyed;
+ }
+
+ public String getName()
+ {
+ return NAME;
+ }
+
+ public void rain()
+ {
+ rained = true;
+ System.out.println("rain!");
+ }
+
+ public boolean isRained()
+ {
+ return rained;
+ }
+
+}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/CloudController.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/CloudController.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/CloudController.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import javax.enterprise.context.Conversation;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+public @Named class CloudController
+{
+ @Inject Conversation conversation;
+
+ public String getBeginConversation()
+ {
+ conversation.begin();
+ return "long-running conversation begun";
+ }
+
+}
Deleted:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java 2010-02-19
06:36:14 UTC (rev 5887)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -1,67 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
-
-import javax.enterprise.context.Conversation;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.AnyLiteral;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-/**
- * @author Nicklas Karlsson
- */
-@Artifact
-@SpecVersion(spec="cdi", version="20091101")
-public class ConversationBeginTest extends AbstractJSR299Test
-{
-
- @Override
- public void beforeMethod()
- {
- super.beforeMethod();
- Conversation conversation = getInstanceByType(Conversation.class, new
AnyLiteral());
- if (!conversation.isTransient())
- {
- conversation.end();
- }
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "f")
- public void testConversationBeginMakesConversationLongRunning()
- {
- Conversation conversation = getInstanceByType(Conversation.class, new
AnyLiteral());
- assert conversation.isTransient();
- conversation.begin();
- assert !conversation.isTransient();
- }
-
- @Test(groups = { "contexts" }, expectedExceptions =
IllegalStateException.class)
- @SpecAssertion(section = "6.7.5", id = "r")
- public void testBeginAlreadyLongRunningConversationThrowsException()
- {
- Conversation conversation = getInstanceByType(Conversation.class, new
AnyLiteral());
- assert conversation.isTransient();
- conversation.begin();
- conversation.begin();
- }
-
-}
\ No newline at end of file
Deleted:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2010-02-19
06:36:14 UTC (rev 5887)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -1,92 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
-
-import java.lang.annotation.Annotation;
-
-import javax.enterprise.context.Conversation;
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Default;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.AnyLiteral;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-/**
- * @author Nicklas Karlsson
- */
-@Artifact
-@SpecVersion(spec="cdi", version="20091101")
-public class ConversationContextTest extends AbstractJSR299Test
-{
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "e")
- public void testDefaultConversationIsTransient()
- {
- assert getInstanceByType(Conversation.class, new AnyLiteral()).isTransient();
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.5", id = "iaa")
- public void testBeanWithTypeConversation()
- {
- assert getBeans(Conversation.class, new AnyLiteral()).size() == 1;
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.5", id = "ib")
- public void testBeanWithRequestScope()
- {
- assert getBeans(Conversation.class, new
AnyLiteral()).iterator().next().getScope().equals(RequestScoped.class);
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.5", id = "id")
- public void testBeanWithBindingCurrent()
- {
- boolean found = false;
- for (Annotation binding : getBeans(Conversation.class, new
AnyLiteral()).iterator().next().getQualifiers())
- {
- if (binding.annotationType().equals(Default.class))
- {
- found = true;
- }
- }
- assert found;
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.5", id = "l")
- public void testTransientConversationHasNullId()
- {
- Conversation conversation = getInstanceByType(Conversation.class, new
AnyLiteral());
- assert conversation.isTransient();
- assert conversation.getId() == null;
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.5", id = "ie")
- public void testBeanWithNameJavaxEnterpriseContextConversation()
- {
- assert getBeans(Conversation.class, new
AnyLiteral()).iterator().next().getName().equals("javax.enterprise.context.conversation");
- }
-
-}
\ No newline at end of file
Deleted:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java 2010-02-19
06:36:14 UTC (rev 5887)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
-
-import javax.enterprise.context.Conversation;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-/**
- * @author Nicklas Karlsson
- */
-@Artifact
-@SpecVersion(spec="cdi", version="20091101")
-public class ConversationEndTest extends AbstractJSR299Test
-{
- @Override
- public void beforeMethod()
- {
- super.beforeMethod();
- Conversation conversation = getInstanceByType(Conversation.class);
- if (!conversation.isTransient())
- {
- conversation.end();
- }
- }
-
- @Test(groups = { "contexts" })
- @SpecAssertions({
- @SpecAssertion(section = "6.7.4", id = "g"),
- @SpecAssertion(section = "6.7.5", id = "k"),
- @SpecAssertion(section = "6.7.5", id = "o")
- })
- public void testConversationEndMakesConversationTransient()
- {
- Conversation conversation = getInstanceByType(Conversation.class);
- assert conversation.isTransient();
- conversation.begin();
- assert !conversation.isTransient();
- conversation.end();
- assert conversation.isTransient();
- }
-
- @Test(groups = { "contexts" }, expectedExceptions =
IllegalStateException.class)
- @SpecAssertion(section = "6.7.5", id = "q")
- public void testEndTransientConversationThrowsException()
- {
- Conversation conversation = getInstanceByType(Conversation.class);
- assert conversation.isTransient();
- conversation.end();
- }
-
-}
\ No newline at end of file
Deleted:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java 2010-02-19
06:36:14 UTC (rev 5887)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
-
-import javax.enterprise.context.Conversation;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-/**
- * @author Nicklas Karlsson
- */
-@Artifact
-@SpecVersion(spec="cdi", version="20091101")
-public class ConversationIdSetByApplicationTest extends AbstractJSR299Test
-{
-
- @Test(groups = { "contexts" })
- @SpecAssertions({
- @SpecAssertion(section = "6.7.4", id = "ha"),
- @SpecAssertion(section = "6.7.5", id = "j")
- })
- public void testConversationIdMayBeSetByApplication()
- {
- Conversation conversation = getInstanceByType(Conversation.class);
- conversation.begin("foo");
- assert conversation.getId().equals("foo");
- }
-
-}
\ No newline at end of file
Deleted:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java 2010-02-19
06:36:14 UTC (rev 5887)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
-
-import javax.enterprise.context.Conversation;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-/**
- * @author Nicklas Karlsson
- *
- */
-@Artifact
-@SpecVersion(spec="cdi", version="20091101")
-public class ConversationIdSetByContainerTest extends AbstractJSR299Test
-{
-
- @Test(groups = { "contexts" })
- @SpecAssertions({
- @SpecAssertion(section = "6.7.4", id = "hb"),
- @SpecAssertion(section = "6.7.5", id = "j")
- })
- public void testConversationBeginMakesConversationLongRunning()
- {
- Conversation conversation = getInstanceByType(Conversation.class);
- conversation.begin();
- assert conversation.getId() != null;
- }
-
-}
\ No newline at end of file
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationStatusServlet.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationStatusServlet.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationStatusServlet.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.jsr299.tck.impl.OldSPIBridge;
+
+public class ConversationStatusServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = 2984756941080790899L;
+
+ @Inject
+ private BeanManager beanManager;
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ String method = req.getParameter("method");
+ if ("cid".equals(method))
+ {
+ Conversation conversation = OldSPIBridge.getInstanceByType(beanManager,
Conversation.class);
+ serializeToResponse(conversation.getId(), resp);
+ }
+ else if ("cloudDestroyed".equals(method))
+ {
+ if (Cloud.isDestroyed())
+ {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ }
+ else
+ {
+ resp.setStatus(208);
+ }
+ }
+ else if ("invalidateSession".equals(method))
+ {
+ req.getSession().invalidate();
+ }
+ else if ("resetCloud".equals(method))
+ {
+ Cloud.setDestroyed(false);
+ }
+ else
+ {
+ resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ private void serializeToResponse(Object object, HttpServletResponse resp) throws
IOException
+ {
+ ObjectOutputStream oos = new ObjectOutputStream(resp.getOutputStream());
+ oos.writeObject(object);
+ oos.flush();
+ oos.close();
+ }
+
+}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTestPhaseListener.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTestPhaseListener.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTestPhaseListener.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,80 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.jsr299.tck.api.JSR299Configuration;
+import org.jboss.jsr299.tck.impl.OldSPIBridge;
+import org.jboss.testharness.impl.ConfigurationFactory;
+
+public class ConversationTestPhaseListener implements PhaseListener
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1197355854770726526L;
+
+ public static final String ACTIVE_BEFORE_APPLY_REQUEST_VALUES_HEADER_NAME =
"org.jboss.jsr299.tck.activeBeforeApplyRequestValues";
+
+ private boolean activeBeforeApplyRequestValues;
+
+ public void afterPhase(PhaseEvent event)
+ {
+ }
+
+ public void beforePhase(PhaseEvent event)
+ {
+ JSR299Configuration configuration =
ConfigurationFactory.get(JSR299Configuration.class);
+ if (event.getPhaseId().equals(PhaseId.APPLY_REQUEST_VALUES))
+ {
+ try
+ {
+
configuration.getManagers().getManager().getContext(ConversationScoped.class);
+ activeBeforeApplyRequestValues = true;
+ }
+ catch (ContextNotActiveException e)
+ {
+ activeBeforeApplyRequestValues = false;
+ }
+ }
+ if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
+ {
+ BeanManager beanManager = configuration.getManagers().getManager();
+ Conversation conversation = OldSPIBridge.getInstanceByType(beanManager,
Conversation.class);
+ HttpServletResponse response = (HttpServletResponse)
event.getFacesContext().getExternalContext().getResponse();
+ response.addHeader(AbstractConversationTest.CID_HEADER_NAME,
conversation.getId() == null ? " null" : conversation.getId());
+ response.addHeader(AbstractConversationTest.LONG_RUNNING_HEADER_NAME,
String.valueOf(!conversation.isTransient()));
+ response.addHeader(Cloud.RAINED_HEADER_NAME, new
Boolean(OldSPIBridge.getInstanceByType(beanManager, Cloud.class).isRained()).toString());
+ response.addHeader(ACTIVE_BEFORE_APPLY_REQUEST_VALUES_HEADER_NAME, new
Boolean(activeBeforeApplyRequestValues).toString());
+ }
+ }
+
+ public PhaseId getPhaseId()
+ {
+ return PhaseId.ANY_PHASE;
+ }
+
+}
Deleted:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java 2010-02-19
06:36:14 UTC (rev 5887)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
-
-import javax.enterprise.context.Conversation;
-
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.test.audit.annotations.SpecAssertion;
-import org.jboss.test.audit.annotations.SpecAssertions;
-import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.testharness.impl.packaging.Artifact;
-import org.testng.annotations.Test;
-
-/**
- * @author Dan Allen
- */
-@Artifact
-@SpecVersion(spec="cdi", version="20091101")
-public class ConversationTimeoutTest extends AbstractJSR299Test
-{
- @Test
- @SpecAssertion(section = "6.7.5", id = "m")
- public void testConversationHasDefaultTimeout()
- {
- Conversation conversation = getInstanceByType(Conversation.class);
- assert conversation.getTimeout() > 0;
- }
-
- @Test
- @SpecAssertions({
- @SpecAssertion(section = "6.7.5", id = "m"),
- @SpecAssertion(section = "6.7.5", id = "n")
- })
- public void testSetConversationTimeoutOverride()
- {
- Conversation conversation = getInstanceByType(Conversation.class);
- long oldValue = conversation.getTimeout();
- conversation.setTimeout(1500);
- assert conversation.getTimeout() == 1500;
- conversation.setTimeout(oldValue);
- }
-}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cumulus.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cumulus.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Cumulus.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@ConversationScoped
+@Named
+public class Cumulus implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ private static final int timeout = 15000;
+ private static final String customCid = "humilis";
+
+ @Inject
+ private Conversation conversation;
+
+ public void beginConversation()
+ {
+ conversation.begin();
+ }
+
+ public void beginConversationIdentifiedByCustomIdentifier()
+ {
+ conversation.begin(customCid);
+ }
+
+ public String beginConversationAndSwallowException()
+ {
+ try
+ {
+ conversation.begin();
+ return "error";
+ }
+ catch (IllegalStateException e)
+ {
+ return "home";
+ }
+ }
+
+ public void beginConversationAndSetTimeout()
+ {
+ conversation.begin();
+ conversation.setTimeout(timeout);
+ }
+
+ public void endConversation()
+ {
+ conversation.end();
+ }
+
+ public String endConversationAndSwallowException()
+ {
+ try
+ {
+ conversation.end();
+ return "error";
+ }
+ catch (IllegalStateException e)
+ {
+ return "home";
+ }
+ }
+
+ public boolean isConversationIdentifiedByCustomIdentifier()
+ {
+ return !conversation.isTransient() &&
conversation.getId().equals(customCid);
+ }
+
+ public boolean isConversationIdentifierNull()
+ {
+ return conversation.getId() == null;
+ }
+
+ public boolean isConversationTimeoutSetProperly()
+ {
+ return conversation.getTimeout() == timeout;
+ }
+
+ public boolean isConversationHasDefaultTimeout()
+ {
+ return conversation.getTimeout() > 0;
+ }
+}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/InvalidatingSessionDestroysConversationTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/InvalidatingSessionDestroysConversationTest.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/InvalidatingSessionDestroysConversationTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WebXml;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+
+/**
+ * @author Nicklas Karlsson
+ */
+@Artifact(addCurrentPackage=false)
+(a)Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class, CloudController.class})
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination="WEB-INF/faces-config.xml",
source="faces-config.xml"),
+ @Resource(destination="clouds.jspx", source="clouds.jsf"),
+ @Resource(destination="cloud.jspx", source="cloud.jsf")
+})
+(a)WebXml("web.xml")
+@SpecVersion(spec="cdi", version="20091101")
+public class InvalidatingSessionDestroysConversationTest extends
AbstractConversationTest
+{
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "qa")
+ // TODO this test doesn't precisely probe the boundaries of the service() method
+ public void testInvalidatingSessionDestroysConversation() throws Exception
+ {
+ WebClient webClient = new WebClient();
+ resetCloud(webClient);
+ webClient.getPage(getPath("/clouds.jsf"));
+ assert !isCloudDestroyed(webClient);
+ invalidateSession(webClient);
+ assert isCloudDestroyed(webClient);
+ }
+
+}
\ No newline at end of file
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/LongRunningConversationPropagatedByFacesContextTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/LongRunningConversationPropagatedByFacesContextTest.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/LongRunningConversationPropagatedByFacesContextTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,96 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WebXml;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
+
+/**
+ * @author Nicklas Karlsson
+ */
+@Artifact(addCurrentPackage=false)
+(a)Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class})
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination="WEB-INF/faces-config.xml",
source="faces-config.xml"),
+ @Resource(destination="storm.jspx", source="storm.jsf"),
+ @Resource(destination="thunder.jspx", source="thunder.jsf"),
+ @Resource(destination="lightening.jspx", source="lightening.jsf")
+})
+(a)WebXml("web.xml")
+@SpecVersion(spec="cdi", version="20091101")
+public class LongRunningConversationPropagatedByFacesContextTest extends
AbstractConversationTest
+{
+
+ private static final String STORM_STRENGTH = "12";
+ private static final String REDIRECT_STORM_STRENGTH = "15";
+
+ @Test(groups = { "contexts" })
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "l"),
+ @SpecAssertion(section = "2.4.1", id="ba")
+ })
+
+ public void testConversationPropagated() throws Exception
+ {
+ WebClient webClient = new WebClient();
+ HtmlPage storm = webClient.getPage(getPath("/storm.jsf"));
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "beginConversationButton");
+ storm = beginConversationButton.click();
+ HtmlTextInput stormStrength = getFirstMatchingElement(storm, HtmlTextInput.class,
"stormStrength");
+ stormStrength.setValueAttribute(STORM_STRENGTH);
+ String stormCid = getCid(storm);
+ HtmlSubmitInput thunderButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "thunderButton");
+ HtmlPage thunder = thunderButton.click();
+ assert stormCid.equals(getCid(thunder));
+ stormStrength = getFirstMatchingElement(thunder, HtmlTextInput.class,
"stormStrength");
+ assert stormStrength.getValueAttribute().equals(STORM_STRENGTH);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "m")
+ public void testConversationPropagatedOverRedirect() throws Exception
+ {
+ WebClient webClient = new WebClient();
+ HtmlPage storm = webClient.getPage(getPath("/storm.jsf"));
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "beginConversationButton");
+ storm = beginConversationButton.click();
+ HtmlTextInput stormStrength = getFirstMatchingElement(storm, HtmlTextInput.class,
"stormStrength");
+ stormStrength.setValueAttribute(REDIRECT_STORM_STRENGTH);
+ String stormCid = getCid(storm);
+ HtmlSubmitInput lighteningButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "lighteningButton");
+ HtmlPage lightening = lighteningButton.click();
+ assert
lightening.getWebResponse().getRequestUrl().toString().contains("lightening.jsf");
+ assert stormCid.equals(getCid(lightening));
+ stormStrength = getFirstMatchingElement(lightening, HtmlTextInput.class,
"stormStrength");
+ assert stormStrength.getValueAttribute().equals(REDIRECT_STORM_STRENGTH);
+ }
+
+}
\ No newline at end of file
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ManualCidPropagationTest.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ManualCidPropagationTest.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ManualCidPropagationTest.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.war.WebXml;
+import org.testng.annotations.Test;
+
+import com.gargoylesoftware.htmlunit.WebClient;
+import com.gargoylesoftware.htmlunit.html.HtmlPage;
+import com.gargoylesoftware.htmlunit.html.HtmlSubmitInput;
+
+/**
+ * @author Nicklas Karlsson
+ * @author Dan Allen
+ *
+ */
+@Artifact(addCurrentPackage=false)
+(a)Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class, CloudController.class})
+@IntegrationTest(runLocally=true)
+@Resources({
+ @Resource(destination="cloud.jspx", source="cloud.jsf"),
+ @Resource(destination="storm.jspx", source="storm.jsf"),
+ @Resource(destination="clouds.jspx", source="clouds.jsf"),
+ @Resource(destination="/WEB-INF/faces-config.xml",
source="faces-config.xml")
+})
+(a)WebXml("web.xml")
+@SpecVersion(spec="cdi", version="20091101")
+public class ManualCidPropagationTest extends AbstractConversationTest
+{
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "n")
+ public void testManualCidPropagation() throws Exception
+ {
+ WebClient webClient = new WebClient();
+ HtmlPage storm = webClient.getPage(getPath("/storm.jsf"));
+ HtmlSubmitInput beginConversationButton = getFirstMatchingElement(storm,
HtmlSubmitInput.class, "beginConversationButton");
+ storm = beginConversationButton.click();
+
+ String c1 = getCid(storm);
+
+ HtmlPage cloud = webClient.getPage(getPath("/cloud.jsf", c1));
+
+ String c2 = getCid(cloud);
+
+ assert isLongRunning(cloud);
+ assert c1.equals(c2);
+ }
+
+}
Added:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Storm.java
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Storm.java
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/Storm.java 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.jsr299.tck.tests.context.conversation;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named
+@ConversationScoped
+public class Storm implements Serializable
+{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1513633490356967202L;
+
+ @Inject Conversation conversation;
+
+ private String strength;
+
+ public String thunder()
+ {
+ return "thunder";
+ }
+
+ public String lightening()
+ {
+ return "lightening";
+ }
+
+ public void beginConversation()
+ {
+ conversation.begin();
+ }
+
+ public String getStrength()
+ {
+ return strength;
+ }
+
+ public void setStrength(String strength)
+ {
+ this.strength = strength;
+ }
+
+}
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/builtin.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/builtin.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/builtin.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml" version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
/>
+ <jsp:directive.page contentType="text/html" />
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:panelGrid>
+ <h:outputText value="Correct scope: #{builtin.scopeCorrect}"/>
+ <h:outputText value="Correct name: #{builtin.nameCorrect}"/>
+ <h:outputText value="Correct qualifier:
#{builtin.qualifierCorrect}"/>
+ <h:outputText value="Default conversation has null id:
#{builtin.defaultConversationHasNullId}"/>
+ </h:panelGrid>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cloud.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cloud.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cloud.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:outputText value="#{cloud.name}" id="cloudName" />
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/clouds.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/clouds.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/clouds.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:outputText value="#{cloud.name}" />
+ <h:outputText value="#{cloudController.beginConversation}" />
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cumulus.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cumulus.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/cumulus.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml" version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
/>
+ <jsp:directive.page contentType="text/html" />
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:form id="form">
+ <h:panelGrid columns="1">
+ <h:outputText value="Cumulus humilis"
+ rendered="#{cumulus.conversationIdentifiedByCustomIdentifier}" />
+ <h:outputText value="Cumulus congestus"
+ rendered="#{not cumulus.conversationIdentifierNull}" />
+ <h:outputText value="Cumulonimbus"
+ rendered="#{cumulus.conversationTimeoutSetProperly}" />
+ <h:outputText value="Stratocumulus"
+ rendered="#{cumulus.conversationHasDefaultTimeout}" />
+ <h:commandButton action="#{cumulus.beginConversation}"
+ value="Begin conversation" id="beginConversationButton" />
+ <h:commandButton
+ action="#{cumulus.beginConversationIdentifiedByCustomIdentifier}"
+ value="Begin conversation identified by custom identifier"
+ id="beginConversationIdentifiedByCustomIdentifier" />
+ <h:commandButton
+ action="#{cumulus.beginConversationAndSwallowException}"
+ value="Begin conversation and swallow exception"
+ id="beginConversationAndSwallowException" />
+ <h:commandButton
+ action="#{cumulus.beginConversationAndSetTimeout}"
+ value="Begin conversation and set timeout"
+ id="beginConversationAndSetTimeout" />
+ <h:commandButton action="#{cumulus.endConversation}"
+ value="End conversation" id="endConversationButton" />
+ <h:commandButton
+ action="#{cumulus.endConversationAndSwallowException}"
+ value="End conversation and swallow exception"
+ id="endConversationAndSwallowException" />
+ </h:panelGrid>
+ </h:form>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/error.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/error.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/error.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <h1>Expected exception was not thrown!</h1>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/faces-config.xml
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/faces-config.xml
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/faces-config.xml 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,42 @@
+<?xml version="1.0"?>
+<faces-config version="1.2"
+
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-facesconfig_1_2.xsd">
+
+ <lifecycle>
+
<phase-listener>org.jboss.jsr299.tck.tests.context.conversation.ConversationTestPhaseListener</phase-listener>
+ </lifecycle>
+
+ <navigation-rule>
+ <from-view-id>/storm.jspx</from-view-id>
+ <navigation-case>
+ <from-outcome>thunder</from-outcome>
+ <to-view-id>/thunder.jspx</to-view-id>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/storm.jspx</from-view-id>
+ <navigation-case>
+ <from-outcome>lightening</from-outcome>
+ <to-view-id>/lightening.jspx</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/cumulus.jspx</from-view-id>
+ <navigation-case>
+ <from-outcome>home</from-outcome>
+ <to-view-id>/home.jspx</to-view-id>
+ <redirect/>
+ </navigation-case>
+ <navigation-case>
+ <from-outcome>error</from-outcome>
+ <to-view-id>/error.jspx</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
+
+</faces-config>
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/home.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/home.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/home.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <h1>Hello world!</h1>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/lightening.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/lightening.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/lightening.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml" version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
/>
+ <jsp:directive.page contentType="text/html" />
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <h:inputText value="#{storm.strength}" id="stormStrength"
/>
+ </h:form>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/rain.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/rain.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/rain.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <h:commandButton action="#{storm.beginConversation}"
value="Thunder" id="beginConversationButton"/>
+ <h:commandButton action="#{cloud.rain}" value="Rain"
id="rain"/>
+ </h:form>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/storm.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/storm.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/storm.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml"
+ version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
+ <jsp:directive.page contentType="text/html"/>
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:form id="form">
+ <h:inputText value="#{storm.strength}" id="stormStrength"
/>
+ <h:commandButton action="#{storm.beginConversation}"
value="Thunder" id="beginConversationButton"/>
+ <h:commandButton action="#{storm.thunder}"
value="Thunder" id="thunderButton"/>
+ <h:commandButton action="#{storm.lightening}"
value="Thunder" id="lighteningButton"/>
+ </h:form>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
\ No newline at end of file
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/thunder.jsf
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/thunder.jsf
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/thunder.jsf 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,23 @@
+<?xml version="1.0"?>
+<jsp:root
xmlns:jsp="http://java.sun.com/JSP/Page"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:s="http://jboss.com/products/seam/taglib"
+
xmlns="http://www.w3.org/1999/xhtml" version="2.0">
+ <jsp:output doctype-root-element="html"
+ doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
+
doctype-system="http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional...
/>
+ <jsp:directive.page contentType="text/html" />
+ <html>
+ <head>
+ </head>
+ <body>
+ <f:view>
+ <h:form>
+ <h:inputText value="#{storm.strength}" id="stormStrength"
/>
+ </h:form>
+ </f:view>
+ </body>
+ </html>
+</jsp:root>
+
Added:
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml
===================================================================
---
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml
(rev 0)
+++
cdi-tck/branches/1.0/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml 2010-02-19
09:55:53 UTC (rev 5888)
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app version="2.5"
+
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">
+
+ <display-name>JSR-299 TCK</display-name>
+
+ <!-- JSF -->
+
+ <servlet>
+ <servlet-name>Faces Servlet</servlet-name>
+ <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Faces Servlet</servlet-name>
+ <url-pattern>*.jsf</url-pattern>
+ </servlet-mapping>
+
+ <context-param>
+ <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
+ <param-value>.jspx</param-value>
+ </context-param>
+
+ <servlet>
+ <servlet-name>Conversation Status Servlet</servlet-name>
+
<servlet-class>org.jboss.jsr299.tck.tests.context.conversation.ConversationStatusServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>Conversation Status Servlet</servlet-name>
+ <url-pattern>/conversation-status</url-pattern>
+ </servlet-mapping>
+
+ <listener>
+
<listener-class>org.jboss.testharness.impl.runner.servlet.HarnessServletListener</listener-class>
+ </listener>
+
+ <session-config>
+ <session-timeout>10</session-timeout>
+ </session-config>
+
+</web-app>