Author: dan.j.allen
Date: 2009-07-17 17:26:24 -0400 (Fri, 17 Jul 2009)
New Revision: 3081
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationState.java
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningInstancesNotDestroyedTest.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ClientConversationContextTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/Cloud.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/CloudController.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationStatusServlet.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/InvalidatingSessionDestroysConversationTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningConversationPropagatedByFacesContextTest.java
Log:
update to 20090625 spec assertions
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ApplicationContextTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -13,10 +13,9 @@
import com.gargoylesoftware.htmlunit.WebClient;
/**
- *
* @author David Allen
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact
@IntegrationTest(runLocally=true)
@@ -57,6 +56,7 @@
// Make a second request and make sure the same context is used
TextPage secondRequestResult = webClient.getPage(getContextPath() +
"IntrospectApplication");
assert secondRequestResult.getContent() != null;
+ // should be same random number
assert Double.parseDouble(secondRequestResult.getContent()) ==
Double.parseDouble(firstRequestResult.getContent());
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/EJBApplicationContextTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -13,7 +13,7 @@
*
* @author David Allen
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact
@IntegrationTest
@@ -22,7 +22,7 @@
{
@Test(groups = { "broken", "contexts", "webservice",
"integration" })
@SpecAssertion(section = "6.7.3", id = "b")
- public void testApplicationScopeActiveDuringWebSericeInvocation()
+ public void testApplicationScopeActiveDuringWebServiceInvocation()
{
//TODO This test might work better with a separate client over HTTP
FeederService birdFeeder = getInstanceByType(FeederService.class);
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -7,6 +7,7 @@
import javax.ejb.TimerService;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Current;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
@Stateless
@@ -19,6 +20,9 @@
@Current
private BeanManager beanManager;
+
+ @Current
+ private Instance<SimpleApplicationBean> simpleApplicationBeanInstance;
private static boolean applicationScopeActive = false;
private static double beanId = 0.0d;
@@ -52,14 +56,14 @@
applicationScopeActive = true;
if (beanId > 0.0)
{
- if (beanId ==
org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(beanManager,SimpleApplicationBean.class).getId())
+ if (beanId == simpleApplicationBeanInstance.get().getId())
{
sameBean = true;
}
}
else
{
- beanId =
org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(beanManager,SimpleApplicationBean.class).getId();
+ beanId = simpleApplicationBeanInstance.get().getId();
}
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationBeginTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -8,22 +8,43 @@
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact
public class ConversationBeginTest extends AbstractJSR299Test
{
+ @Override
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ Conversation conversation = getInstanceByType(Conversation.class);
+ if (conversation.isLongRunning())
+ {
+ conversation.end();
+ }
+ }
+
@Test(groups = { "contexts" })
@SpecAssertion(section = "6.7.4", id = "f")
public void testConversationBeginMakesConversationLongRunning()
{
Conversation conversation = getInstanceByType(Conversation.class);
+ assert conversation.isTransient();
conversation.begin();
assert conversation.isLongRunning();
}
+ @Test(groups = { "contexts" }, expectedExceptions =
IllegalStateException.class)
+ @SpecAssertion(section = "6.7.5", id = "r")
+ public void testBeginAlreadyLongRunningConversationThrowsException()
+ {
+ Conversation conversation = getInstanceByType(Conversation.class);
+ assert conversation.isTransient();
+ conversation.begin();
+ conversation.begin();
+ }
+
}
\ No newline at end of file
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationContextTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -13,7 +13,6 @@
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
*
* Spec version: 20090625
@@ -43,7 +42,7 @@
assert
getBeans(Conversation.class).iterator().next().getScopeType().equals(RequestScoped.class);
}
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts", "rewrite" })
@SpecAssertion(section = "6.7.5", id = "ic")
public void testBeanWithDeploymentTypeStandard()
{
@@ -65,7 +64,7 @@
assert found;
}
- @Test(groups = { "contexts", "ri-broken" })
+ @Test(groups = { "contexts" })
@SpecAssertion(section = "6.7.5", id = "ie")
public void testBeanWithNameJavaxEnterpriseContextConversation()
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationEndTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -3,29 +3,55 @@
import javax.enterprise.context.Conversation;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact
public class ConversationEndTest extends AbstractJSR299Test
{
+ @Override
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ Conversation conversation = getInstanceByType(Conversation.class);
+ if (conversation.isLongRunning())
+ {
+ conversation.end();
+ }
+ }
@Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "g")
+ @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.isLongRunning();
+ assert !conversation.isTransient();
conversation.end();
assert !conversation.isLongRunning();
+ 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
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByApplicationTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -3,22 +3,44 @@
import javax.enterprise.context.Conversation;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact
public class ConversationIdSetByApplicationTest extends AbstractJSR299Test
{
-
+ @Override
+ public void beforeMethod()
+ {
+ super.beforeMethod();
+ Conversation conversation = getInstanceByType(Conversation.class);
+ if (conversation.isLongRunning())
+ {
+ conversation.end();
+ }
+ }
+
+ @Test(groups = { "contexts", "ri-broken" })
+ @SpecAssertion(section = "6.7.5", id = "l")
+ public void testTransientConversationHasNullId()
+ {
+ Conversation conversation = getInstanceByType(Conversation.class);
+ assert !conversation.isLongRunning();
+ assert conversation.getId() == null;
+ }
+
@Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "ha")
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "ha"),
+ @SpecAssertion(section = "6.7.5", id = "j")
+ })
public void testConversationIdMayBeSetByApplication()
{
Conversation conversation = getInstanceByType(Conversation.class);
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationIdSetByContainerTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -3,27 +3,30 @@
import javax.enterprise.context.Conversation;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact
public class ConversationIdSetByContainerTest extends AbstractJSR299Test
{
@Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "f")
+ @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.isLongRunning();
+ assert conversation.getId() != null;
}
}
\ No newline at end of file
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ConversationTimeoutTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -0,0 +1,41 @@
+package org.jboss.jsr299.tck.tests.context.conversation;
+
+import javax.enterprise.context.Conversation;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+/**
+ * @author Dan Allen
+ *
+ * Spec version: 20090625
+ */
+@Artifact
+public class ConversationTimeoutTest extends AbstractJSR299Test
+{
+ @Test
+ @SpecAssertion(section = "6.7.5", id = "m")
+ public void testConversationHasDefaultTimeout()
+ {
+ Conversation conversation = getInstanceByType(Conversation.class);
+ System.out.println(conversation.getTimeout());
+ 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);
+ }
+}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/AbstractConversationTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -1,6 +1,5 @@
package org.jboss.jsr299.tck.tests.context.conversation.client;
-import java.io.ObjectInputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
@@ -16,33 +15,15 @@
public abstract class AbstractConversationTest extends AbstractJSR299Test
{
+ // TODO this should be part of the JSR-299 API
+ 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";
+
private static final long TIMEOUT = 200;
- protected String getCid(HttpClient client) throws Exception
- {
- HttpMethod method = new GetMethod(getConversationStatusPath("cid"));
- ObjectInputStream ois = null;
- try
- {
- client.executeMethod(method);
- ois = new ObjectInputStream(method.getResponseBodyAsStream());
- return (String) ois.readObject();
- }
- finally
- {
- if (ois != null)
- {
- ois.close();
- }
- method.releaseConnection();
- }
- }
-
-
-
protected boolean isCloudDestroyed(HttpClient client) throws Exception
{
HttpMethod method = new
GetMethod(getConversationStatusPath("cloudDestroyed"));
@@ -100,14 +81,14 @@
return new URL(getConversationStatusPath(method));
}
- protected String request(HttpClient client, String viewId) throws Exception
+ protected ConversationState request(HttpClient client, String viewId) throws
Exception
{
HttpMethod method = new GetMethod(getPath(viewId));
try
{
client.executeMethod(method);
assert method.getStatusCode() == 200;
- return method.getResponseHeader(CID_HEADER_NAME).getValue();
+ return new
ConversationState(method.getResponseHeader(CID_HEADER_NAME).getValue(),
Boolean.valueOf(method.getResponseHeader(LONG_RUNNING_HEADER_NAME).getValue()));
}
finally
{
@@ -115,6 +96,11 @@
}
}
+ protected ConversationState request(HttpClient client, String viewId,
ConversationState c) throws Exception
+ {
+ return request(client, viewId + "?" + CID_REQUEST_PARAMETER_NAME +
"=" + c.getId());
+ }
+
protected String getBodyAsString(HttpClient client, String viewId) throws Exception
{
HttpMethod method = new GetMethod(getPath(viewId));
@@ -145,6 +131,11 @@
}
}
+ protected boolean hasRained(HttpClient client, String viewId, ConversationState c)
throws Exception
+ {
+ return hasRained(client, viewId + "?" + CID_REQUEST_PARAMETER_NAME +
"=" + c.getId());
+ }
+
protected String getPath(String viewId)
{
return getContextPath() + viewId;
@@ -165,16 +156,16 @@
}
}
- protected <T> Set<T> getElements(HtmlElement rootElement, Class<T>
elementClass)
+ protected <T> Set<T> getElements(HtmlElement rootElement, Class<T>
elementClass)
{
Set<T> result = new HashSet<T>();
- for (HtmlElement element : rootElement.getAllHtmlChildElements())
+ for (HtmlElement element : rootElement.getAllHtmlChildElements())
{
result.addAll(getElements(element, elementClass));
}
- if (elementClass.isInstance(rootElement))
+ if (elementClass.isInstance(rootElement))
{
result.add(elementClass.cast(rootElement));
}
@@ -182,11 +173,11 @@
}
- protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page,
Class<T> elementClass, String id)
+ protected <T extends HtmlElement> T getFirstMatchingElement(HtmlPage page,
Class<T> elementClass, String id)
{
Set<T> inputs = getElements(page.getBody(), elementClass);
- for (T input : inputs)
+ for (T input : inputs)
{
if (input.getId().contains(id))
{
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ClientConversationContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ClientConversationContextTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ClientConversationContextTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -2,6 +2,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.Classes;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -11,10 +12,10 @@
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
+ * @author Dan Allen
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact(addCurrentPackage=false)
@Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class, CloudController.class})
@@ -31,24 +32,29 @@
{
@Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "hb")
+ @SpecAssertions({
+ @SpecAssertion(section = "6.7.4", id = "hb"),
+ @SpecAssertion(section = "6.7.4", id = "o")
+ })
public void testConversationIdSetByContainerIsUnique() throws Exception
{
HttpClient client = new HttpClient();
- request(client, "/home.jsf");
- String cid1 = getCid(client);
- request(client, "/home.jsf");
- String cid2 = getCid(client);
- assert !cid1.equals(cid2);
+ ConversationState c1 = request(client, "/home.jsf");
+ ConversationState c2 = request(client, "/home.jsf");
+ assert c1.isTransient();
+ assert c2.isTransient();
+ assert !c1.getId().equals(c2.getId());
}
@Test(groups = { "contexts" })
@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
{
HttpClient client = new HttpClient();
resetCloud(client);
- request(client, "/cloud.jsf");
+ ConversationState c = request(client, "/cloud.jsf");
+ assert c.isTransient();
assert isCloudDestroyed(client);
}
@@ -58,8 +64,10 @@
{
HttpClient client = new HttpClient();
resetCloud(client);
- request(client, "/clouds.jsf");
+ ConversationState c = request(client, "/clouds.jsf");
assert !isCloudDestroyed(client);
+ c = request(client, "/home.jsf", c);
+ assert c.isLongRunning();
}
@Test(groups = { "contexts" })
@@ -67,9 +75,10 @@
public void testManualCidPropagation() throws Exception
{
HttpClient client = new HttpClient();
- String cid = request(client, "/clouds.jsf");
- String cid2 = request(client, "/clouds.jsf?cid=" + cid);
- assert cid.equals(cid2);
+ ConversationState c1 = request(client, "/clouds.jsf");
+ ConversationState c2 = request(client, "/clouds.jsf", c1);
+ assert c2.isLongRunning();
+ assert c1.getId().equals(c2.getId());
}
@Test(groups = { "contexts" })
@@ -77,24 +86,37 @@
public void testConversationNotPropagated() throws Exception
{
HttpClient client = new HttpClient();
- String cid = request(client, "/clouds.jsf");
- String cid2 = request(client, "/clouds.jsf");
- assert !cid.equals(cid2);
+ ConversationState c1 = request(client, "/clouds.jsf");
+ ConversationState c2 = request(client, "/clouds.jsf");
+ assert c1.isTransient();
+ assert c2.isTransient();
+ assert !c1.getId().equals(c2.getId());
}
@Test(groups = { "contexts" })
@SpecAssertion(section = "6.7.4", id = "p")
- public void testConversationsDontCrossSessionBoundary() throws Exception
+ public void testConversationsDontCrossSessionBoundary1() throws Exception
{
HttpClient client = new HttpClient();
- String cid = request(client, "/rain.jsf");
- assert hasRained(client, "/cloud.jsf?cid=" + cid);
+ ConversationState c1 = request(client, "/rain.jsf");
+ assert hasRained(client, "/cloud.jsf", c1);
invalidateSession(client);
- assert !hasRained(client, "/cloud.jsf?cid=" + cid);
+ assert !hasRained(client, "/cloud.jsf", c1);
}
@Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "b")
+ @SpecAssertion(section = "6.7.4", id = "p")
+ public void testConversationsDontCrossSessionBoundary2() throws Exception
+ {
+ HttpClient client1 = new HttpClient();
+ HttpClient client2 = new HttpClient();
+ ConversationState c1 = request(client1, "/rain.jsf");
+ assert hasRained(client1, "/cloud.jsf", c1);
+ assert !hasRained(client2, "/cloud.jsf", c1);
+ }
+
+ @Test(groups = { "contexts" })
+ @SpecAssertion(section = "6.7.4", id = "a")
public void testConversationActiveDuringNonFacesRequest() throws Exception
{
HttpClient client = new HttpClient();
@@ -106,7 +128,9 @@
public void
testConversationPropagationToNonExistentConversationLeadsToTransientConversation() throws
Exception
{
HttpClient client = new HttpClient();
- assert !request(client,
"/cloud.jsf?cid=org.jboss.jsr299").equals("org.jboss.jsr299");
+ ConversationState c1 = request(client, "/cloud.jsf", new
ConversationState("org.jboss.jsr299", false));
+ assert c1.isTransient();
+ assert !c1.getId().equals("org.jboss.jsr299");
}
}
\ No newline at end of file
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/Cloud.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/Cloud.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/Cloud.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -6,11 +6,8 @@
import javax.enterprise.context.ConversationScoped;
import javax.enterprise.inject.Named;
-@ConversationScoped
-@Named
-public class Cloud implements Serializable
+public @Named @ConversationScoped class Cloud implements Serializable
{
-
public static final String NAME = Cloud.class.getName() + ".Pete";
public static final String RAINED_HEADER_NAME = Cloud.class.getName() +
".rained";
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/CloudController.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/CloudController.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/CloudController.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -4,16 +4,14 @@
import javax.enterprise.inject.Current;
import javax.enterprise.inject.Named;
-@Named
-public class CloudController
+public @Named class CloudController
{
-
@Current Conversation conversation;
public String getBeginConversation()
{
conversation.begin();
- return "begun conversation";
+ return "long-running conversation begun";
}
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationState.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationState.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationState.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -0,0 +1,33 @@
+package org.jboss.jsr299.tck.tests.context.conversation.client;
+
+/**
+ * A simple bean to hold the state of the conversation that
+ * was returned in the headers of the request.
+ */
+public class ConversationState
+{
+ private String id;
+
+ private boolean longRunning;
+
+ public ConversationState(String id, boolean longRunning)
+ {
+ this.id = id;
+ this.longRunning = longRunning;
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public boolean isLongRunning()
+ {
+ return longRunning;
+ }
+
+ public boolean isTransient()
+ {
+ return !longRunning;
+ }
+}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationStatusServlet.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationStatusServlet.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationStatusServlet.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -4,15 +4,21 @@
import java.io.ObjectOutputStream;
import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.Current;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
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.JSR299ConfigurationImpl;
+import org.jboss.jsr299.tck.impl.OldSPIBridge;
public class ConversationStatusServlet extends HttpServlet
{
+ @Current
+ private BeanManager beanManager;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
@@ -20,7 +26,8 @@
String method = req.getParameter("method");
if ("cid".equals(method))
{
-
serializeToResponse(org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(JSR299ConfigurationImpl.get().getManagers().getManager(),Conversation.class).getId(),
resp);
+ Conversation conversation = OldSPIBridge.getInstanceByType(beanManager,
Conversation.class);
+ serializeToResponse(conversation.getId(), resp);
}
else if ("cloudDestroyed".equals(method))
{
@@ -47,6 +54,21 @@
}
}
+ @Override
+ public void init() throws ServletException
+ {
+ //TODO Remove init code once injection works in servlet container
+ try
+ {
+ InitialContext ic = new InitialContext();
+ beanManager = (BeanManager) ic.lookup("java:app/BeanManager");
+ }
+ catch (NamingException e)
+ {
+ throw new ServletException("Error looking up manager", e);
+ }
+ }
+
private void serializeToResponse(Object object, HttpServletResponse resp) throws
IOException
{
ObjectOutputStream oos = new ObjectOutputStream(resp.getOutputStream());
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ConversationTestPhaseListener.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -3,6 +3,7 @@
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;
@@ -47,9 +48,12 @@
}
if (event.getPhaseId().equals(PhaseId.RENDER_RESPONSE))
{
+ BeanManager beanManager =
JSR299ConfigurationImpl.get().getManagers().getManager();
+ Conversation conversation = OldSPIBridge.getInstanceByType(beanManager,
Conversation.class);
HttpServletResponse response = (HttpServletResponse)
event.getFacesContext().getExternalContext().getResponse();
- response.addHeader(AbstractConversationTest.CID_HEADER_NAME,
OldSPIBridge.getInstanceByType(JSR299ConfigurationImpl.get().getManagers().getManager(),Conversation.class).getId());
- response.addHeader(Cloud.RAINED_HEADER_NAME, new
Boolean(OldSPIBridge.getInstanceByType(JSR299ConfigurationImpl.get().getManagers().getManager(),Cloud.class).isRained()).toString());
+ response.addHeader(AbstractConversationTest.CID_HEADER_NAME,
conversation.getId());
+ response.addHeader(AbstractConversationTest.LONG_RUNNING_HEADER_NAME,
String.valueOf(conversation.isLongRunning()));
+ 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());
}
}
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/InvalidatingSessionDestroysConversationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/InvalidatingSessionDestroysConversationTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/InvalidatingSessionDestroysConversationTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -11,10 +11,9 @@
import org.testng.annotations.Test;
/**
- *
* @author Nicklas Karlsson
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact(addCurrentPackage=false)
@Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class, CloudController.class})
@@ -29,7 +28,8 @@
{
@Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "q")
+ @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
{
HttpClient client = new HttpClient();
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningConversationPropagatedByFacesContextTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningConversationPropagatedByFacesContextTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningConversationPropagatedByFacesContextTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -15,10 +15,9 @@
import com.gargoylesoftware.htmlunit.html.HtmlTextInput;
/**
- *
* @author Nicklas Karlsson
*
- * Spec version: 20090519
+ * Spec version: 20090625
*/
@Artifact(addCurrentPackage=false)
@Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class})
Deleted:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningInstancesNotDestroyedTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningInstancesNotDestroyedTest.java 2009-07-17
21:25:42 UTC (rev 3080)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/LongRunningInstancesNotDestroyedTest.java 2009-07-17
21:26:24 UTC (rev 3081)
@@ -1,41 +0,0 @@
-package org.jboss.jsr299.tck.tests.context.conversation.client;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.hibernate.tck.annotations.SpecAssertion;
-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.WarArtifactDescriptor;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Nicklas Karlsson
- *
- * Spec version: 20090519
- */
-@Artifact(addCurrentPackage=false)
-(a)Classes({Storm.class, ConversationTestPhaseListener.class,
ConversationStatusServlet.class, Cloud.class, CloudController.class})
-@IntegrationTest(runLocally=true)
-@Resources({
- @Resource(destination=WarArtifactDescriptor.WEB_XML_DESTINATION,
source="web.xml"),
- @Resource(destination="clouds.jspx", source="clouds.jsf"),
- @Resource(destination="WEB-INF/faces-config.xml",
source="faces-config.xml"),
- @Resource(destination="cloud.jspx", source="cloud.jsf")
-})
-public class LongRunningInstancesNotDestroyedTest extends AbstractConversationTest
-{
-
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "k")
- public void testLongRunningConversationInstancesNotDestroyedAtRequestEnd() throws
Exception
- {
- HttpClient client = new HttpClient();
- resetCloud(client);
- request(client, "/clouds.jsf");
- assert !isCloudDestroyed(client);
- }
-
-}
\ No newline at end of file