Author: pete.muir(a)jboss.org
Date: 2009-07-26 14:58:45 -0400 (Sun, 26 Jul 2009)
New Revision: 3252
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ManualCidPropagationTest.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.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/InvalidatingSessionDestroysConversationTest.java
Log:
add getUnderlyingId method to ConversationImpl for internal use, and mark some tests
broken with TODOs
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java 2009-07-26
18:57:47 UTC (rev 3251)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/AbstractConversationManager.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -127,7 +127,7 @@
public void cleanupConversation()
{
log.trace("Cleaning up conversation for " + currentConversation);
- String cid = currentConversation.getId();
+ String cid = currentConversation.getUnderlyingId();
if (currentConversation.isLongRunning())
{
Future<?> terminationHandle = scheduleForTermination(cid,
currentConversation.getTimeout());
@@ -170,7 +170,7 @@
// Conversation.begin(String), we need to unlock the original conversation
// and re-schedule
// it for termination
- String originalCid = currentConversation.getOriginalCid();
+ String originalCid = currentConversation.getOriginalId();
ConversationEntry longRunningConversation = originalCid == null ? null :
longRunningConversations.get(originalCid);
if (longRunningConversation != null)
{
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java 2009-07-26
18:57:47 UTC (rev 3251)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationEntry.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -20,8 +20,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
-import javax.enterprise.context.Conversation;
-
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.context.api.BeanStore;
import org.jboss.webbeans.log.LogProvider;
@@ -37,7 +35,7 @@
private static LogProvider log = Logging.getLogProvider(ConversationEntry.class);
// The conversation
- private Conversation conversation;
+ private ConversationImpl conversation;
// The handle to the asynchronous timeout task
private Future<?> terminationHandle;
// The lock for concurrent access prevention
@@ -51,7 +49,7 @@
* @param cid The conversation ID
* @param terminationHandle The timeout termination handle
*/
- protected ConversationEntry(BeanStore beanStore, Conversation conversation,
Future<?> terminationHandle)
+ protected ConversationEntry(BeanStore beanStore, ConversationImpl conversation,
Future<?> terminationHandle)
{
this.beanStore = beanStore;
// conversation is a proxy so we need to make a "real" instance
@@ -68,7 +66,7 @@
* @param terminationHandle The timeout termination handle
* @return A new conversation entry
*/
- public static ConversationEntry of(BeanStore beanStore, Conversation conversation,
Future<?> terminationHandle)
+ public static ConversationEntry of(BeanStore beanStore, ConversationImpl conversation,
Future<?> terminationHandle)
{
return new ConversationEntry(beanStore, conversation, terminationHandle);
}
@@ -167,7 +165,7 @@
log.trace("Conversation " + conversation + " re-scheduled for
termination");
}
- public Conversation getConversation()
+ public ConversationImpl getConversation()
{
return conversation;
}
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-07-26
18:57:47 UTC (rev 3251)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/conversation/ConversationImpl.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -45,9 +45,9 @@
private static LogProvider log = Logging.getLogProvider(ConversationImpl.class);
// The conversation ID
- private String cid;
+ private String id;
// The original conversation ID (if any)
- private String originalCid;
+ private String originalId;
// Is the conversation long-running?
private boolean longRunning;
// The timeout in milliseconds
@@ -65,9 +65,9 @@
*
* @param conversation The old conversation
*/
- public ConversationImpl(Conversation conversation)
+ public ConversationImpl(ConversationImpl conversation)
{
- this.cid = conversation.getId();
+ this.id = conversation.getUnderlyingId();
this.longRunning = conversation.isLongRunning();
this.timeout = conversation.getTimeout();
}
@@ -81,7 +81,7 @@
@Initializer
public void init(ConversationIdGenerator conversationIdGenerator,
@ConversationInactivityTimeout long timeout)
{
- this.cid = conversationIdGenerator.nextId();
+ this.id = conversationIdGenerator.nextId();
this.timeout = timeout;
this.longRunning = false;
log.debug("Created a new conversation " + this);
@@ -93,19 +93,21 @@
{
throw new IllegalStateException("Attempt to call begin() on a long-running
conversation");
}
- log.debug("Promoted conversation " + cid + " to
long-running");
+ log.debug("Promoted conversation " + id + " to long-running");
longRunning = true;
}
public void begin(String id)
{
- // Store away the (first) change to the conversation ID. If the original
conversation was long-running,
- // we might have to place it back for termination once the request is over.
- if (originalCid == null)
+ // Store away the (first) change to the conversation ID. If the original
+ // conversation was long-running,
+ // we might have to place it back for termination once the request is
+ // over.
+ if (originalId == null)
{
- originalCid = cid;
+ originalId = id;
}
- cid = id;
+ this.id = id;
begin();
}
@@ -115,7 +117,7 @@
{
throw new IllegalStateException("Attempt to call end() on a transient
conversation");
}
- log.debug("Demoted conversation " + cid + " to transient");
+ log.debug("Demoted conversation " + id + " to transient");
this.longRunning = false;
}
@@ -123,7 +125,7 @@
{
if (isLongRunning())
{
- return cid;
+ return id;
}
else
{
@@ -131,6 +133,17 @@
}
}
+ /**
+ * Get the Conversation Id, regardless of whether the conversation is long
+ * running or transient, needed for internal operations
+ *
+ * @return the id
+ */
+ public String getUnderlyingId()
+ {
+ return id;
+ }
+
public long getTimeout()
{
return timeout;
@@ -152,10 +165,10 @@
* @param conversation The new conversation
*
*/
- public void switchTo(Conversation conversation)
+ public void switchTo(ConversationImpl conversation)
{
log.debug("Switched conversation from " + this);
- cid = conversation.getId();
+ id = conversation.getUnderlyingId();
longRunning = conversation.isLongRunning();
timeout = conversation.getTimeout();
log.debug(" to " + this);
@@ -164,12 +177,12 @@
@Override
public String toString()
{
- return "ID: " + cid + ", long-running: " + longRunning +
", timeout: " + timeout + "ms";
+ return "ID: " + id + ", long-running: " + longRunning + ",
timeout: " + timeout + "ms";
}
public void setLongRunning(boolean longRunning)
{
- log.debug("Set conversation " + cid + " to long-running: " +
longRunning);
+ log.debug("Set conversation " + id + " to long-running: " +
longRunning);
this.longRunning = longRunning;
}
@@ -178,28 +191,31 @@
*
* @return The id
*/
- public String getOriginalCid()
+ public String getOriginalId()
{
- return originalCid;
+ return originalId;
}
-
+
@Override
public boolean equals(Object obj)
{
-
- if (obj == null || !(obj instanceof Conversation))
+ if (obj instanceof ConversationImpl)
+ {
+ ConversationImpl that = (ConversationImpl) obj;
+ return (id == null || that.getUnderlyingId() == null) ? false :
id.equals(that.getUnderlyingId());
+ }
+ else
+ {
return false;
- String otherCid = ((Conversation)obj).getId();
- return (cid == null || otherCid == null) ? false : cid.equals(otherCid);
+ }
}
-
+
@Override
public int hashCode()
{
- return cid == null ? super.hashCode() : cid.hashCode();
+ return id == null ? super.hashCode() : id.hashCode();
}
-
public boolean isTransient()
{
return !isLongRunning();
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java 2009-07-26
18:57:47 UTC (rev 3251)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/ConversationAwareViewHandler.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -16,12 +16,12 @@
*/
package org.jboss.webbeans.jsf;
-import javax.enterprise.context.Conversation;
import javax.faces.application.ViewHandler;
import javax.faces.application.ViewHandlerWrapper;
import javax.faces.context.FacesContext;
import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.conversation.ConversationImpl;
/**
* <p>
@@ -66,10 +66,10 @@
public String getActionURL(FacesContext context, String viewId)
{
String actionUrl = super.getActionURL(context, viewId);
- Conversation conversation =
CurrentManager.rootManager().getInstanceByType(Conversation.class);
+ ConversationImpl conversation =
CurrentManager.rootManager().getInstanceByType(ConversationImpl.class);
if (conversation.isLongRunning())
{
- return new
FacesUrlTransformer(actionUrl).appendConversationIdIfNecessary(conversation.getId()).getUrl();
+ return new
FacesUrlTransformer(actionUrl).appendConversationIdIfNecessary(conversation.getUnderlyingId()).getUrl();
}
else
{
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-07-26
18:57:47 UTC (rev 3251)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/jsf/WebBeansPhaseListener.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -22,7 +22,6 @@
*/
package org.jboss.webbeans.jsf;
-import javax.enterprise.context.Conversation;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
@@ -31,6 +30,7 @@
import org.jboss.webbeans.CurrentManager;
import org.jboss.webbeans.context.ConversationContext;
import org.jboss.webbeans.context.SessionContext;
+import org.jboss.webbeans.conversation.ConversationImpl;
import org.jboss.webbeans.conversation.ConversationManager;
import org.jboss.webbeans.log.LogProvider;
import org.jboss.webbeans.log.Logging;
@@ -154,7 +154,7 @@
HttpSession session = PhaseHelper.getHttpSession();
CurrentManager.rootManager().getInstanceByType(HttpSessionManager.class).setSession(session);
CurrentManager.rootManager().getInstanceByType(ConversationManager.class).beginOrRestoreConversation(PhaseHelper.getConversationId());
- String cid =
CurrentManager.rootManager().getInstanceByType(Conversation.class).getId();
+ String cid =
CurrentManager.rootManager().getInstanceByType(ConversationImpl.class).getUnderlyingId();
ConversationContext conversationContext =
CurrentManager.rootManager().getServices().get(ConversationContext.class);
conversationContext.setBeanStore(new ConversationBeanStore(session, cid));
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java
===================================================================
---
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java 2009-07-26
18:57:47 UTC (rev 3251)
+++
ri/trunk/impl/src/main/java/org/jboss/webbeans/servlet/ConversationPropagationFilter.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -18,7 +18,6 @@
import java.io.IOException;
-import javax.enterprise.context.Conversation;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
@@ -29,6 +28,7 @@
import javax.servlet.http.HttpServletResponseWrapper;
import org.jboss.webbeans.CurrentManager;
+import org.jboss.webbeans.conversation.ConversationImpl;
import org.jboss.webbeans.conversation.ConversationManager;
import org.jboss.webbeans.jsf.FacesUrlTransformer;
@@ -66,10 +66,10 @@
@Override
public void sendRedirect(String path) throws IOException
{
- Conversation conversation =
CurrentManager.rootManager().getInstanceByType(Conversation.class);
+ ConversationImpl conversation =
CurrentManager.rootManager().getInstanceByType(ConversationImpl.class);
if (conversation.isLongRunning())
{
- path = new
FacesUrlTransformer(path).toRedirectViewId().toActionUrl().appendConversationIdIfNecessary(conversation.getId()).encode();
+ path = new
FacesUrlTransformer(path).toRedirectViewId().toActionUrl().appendConversationIdIfNecessary(conversation.getUnderlyingId()).encode();
CurrentManager.rootManager().getInstanceByType(ConversationManager.class).cleanupConversation();
}
super.sendRedirect(path);
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-26
18:57:47 UTC (rev 3251)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ClientConversationContextTest.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -31,13 +31,14 @@
public class ClientConversationContextTest extends AbstractConversationTest
{
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts", "broken" })
@SpecAssertions({
@SpecAssertion(section = "6.7.4", id = "hb"),
@SpecAssertion(section = "6.7.4", id = "o")
})
public void testConversationIdSetByContainerIsUnique() throws Exception
{
+ // TODO Test assumes conversation.getId() is available when not in a lrc
HttpClient client = new HttpClient();
ConversationState c1 = request(client, "/home.jsf");
ConversationState c2 = request(client, "/home.jsf");
@@ -58,10 +59,11 @@
assert isCloudDestroyed(client);
}
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts", "broken"})
@SpecAssertion(section = "6.7.4", id = "k")
public void testLongRunningConversationInstancesNotDestroyedAtRequestEnd() throws
Exception
{
+ // TODO Test assumes conversation.getId() is available when not in a lrc
HttpClient client = new HttpClient();
resetCloud(client);
ConversationState c = request(client, "/clouds.jsf");
@@ -70,21 +72,11 @@
assert c.isLongRunning();
}
- @Test(groups = { "contexts" })
- @SpecAssertion(section = "6.7.4", id = "n")
- public void testManualCidPropagation() throws Exception
- {
- HttpClient client = new HttpClient();
- ConversationState c1 = request(client, "/clouds.jsf");
- ConversationState c2 = request(client, "/cloud.jsf", c1);
- assert c2.isLongRunning();
- assert c1.getId().equals(c2.getId());
- }
-
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts", "broken" })
@SpecAssertion(section = "6.7.4", id = "o")
public void testConversationNotPropagated() throws Exception
{
+ // TODO Test assumes conversation.getId() is available when not in a lrc
HttpClient client = new HttpClient();
ConversationState c1 = request(client, "/clouds.jsf");
ConversationState c2 = request(client, "/clouds.jsf");
@@ -93,10 +85,11 @@
assert !c1.getId().equals(c2.getId());
}
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts" , "broken"})
@SpecAssertion(section = "6.7.4", id = "p")
public void testConversationsDontCrossSessionBoundary1() throws Exception
{
+ // TODO Test assumes conversation.getId() is available when not in a lrc
HttpClient client = new HttpClient();
ConversationState c1 = request(client, "/rain.jsf");
assert hasRained(client, "/cloud.jsf", c1);
@@ -104,10 +97,11 @@
assert !hasRained(client, "/cloud.jsf", c1);
}
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts" , "broken"})
@SpecAssertion(section = "6.7.4", id = "p")
public void testConversationsDontCrossSessionBoundary2() throws Exception
{
+ // TODO Test assumes conversation.getId() is available when not in a lrc
HttpClient client1 = new HttpClient();
HttpClient client2 = new HttpClient();
ConversationState c1 = request(client1, "/rain.jsf");
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-26
18:57:47 UTC (rev 3251)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/InvalidatingSessionDestroysConversationTest.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -27,11 +27,12 @@
public class InvalidatingSessionDestroysConversationTest extends
AbstractConversationTest
{
- @Test(groups = { "contexts" })
+ @Test(groups = { "contexts", "broken" })
@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
{
+ // TODO Test assumes conversation.getId() is available when not in a lrc
HttpClient client = new HttpClient();
resetCloud(client);
request(client, "/clouds.jsf");
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ManualCidPropagationTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ManualCidPropagationTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ManualCidPropagationTest.java 2009-07-26
18:58:45 UTC (rev 3252)
@@ -0,0 +1,43 @@
+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
+ * @author Dan Allen
+ *
+ * Spec version: 20090625
+ */
+@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="cloud.jspx", source="cloud.jsf"),
+ @Resource(destination="clouds.jspx", source="clouds.jsf"),
+ @Resource(destination="/WEB-INF/faces-config.xml",
source="faces-config.xml")
+})
+public class ManualCidPropagationTest extends AbstractConversationTest
+{
+
+ @Test(groups = { "contexts", "broken" })
+ @SpecAssertion(section = "6.7.4", id = "n")
+ public void testManualCidPropagation() throws Exception
+ {
+ // TODO Test assumes conversation.getId() is available when not in a lrc
+ HttpClient client = new HttpClient();
+ ConversationState c1 = request(client, "/clouds.jsf");
+ ConversationState c2 = request(client, "/cloud.jsf", c1);
+ assert c2.isLongRunning();
+ assert c1.getId().equals(c2.getId());
+ }
+
+}
Property changes on:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/client/ManualCidPropagationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain