[weld-commits] Weld SVN: r5960 - in cdi-tck/trunk/impl/src/main: resources/org/jboss/jsr299/tck/tests/context/conversation and 1 other directory.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Thu Feb 25 04:40:05 EST 2010


Author: jharting
Date: 2010-02-25 04:40:05 -0500 (Thu, 25 Feb 2010)
New Revision: 5960

Added:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/OutermostFilter.java
Modified:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java
   cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml
Log:
CDITCK-114

Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java	2010-02-24 03:53:20 UTC (rev 5959)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/ClientConversationContextTest.java	2010-02-25 09:40:05 UTC (rev 5960)
@@ -37,7 +37,7 @@
  * @author Dan Allen
  */
 @Artifact(addCurrentPackage=false)
- at Classes({Storm.class, ConversationTestPhaseListener.class, ConversationStatusServlet.class, Cloud.class, CloudController.class, Cumulus.class, BuiltInConversation.class})
+ at Classes({Storm.class, ConversationTestPhaseListener.class, ConversationStatusServlet.class, Cloud.class, CloudController.class, Cumulus.class, BuiltInConversation.class, OutermostFilter.class})
 @IntegrationTest(runLocally=true)
 @Resources({
   @Resource(destination="home.jspx", source="home.jsf"),
@@ -324,6 +324,17 @@
       assert page.getBody().getTextContent().contains("Cumulus congestus");
    }
    
+   @Test(groups = { "contexts" })
+   @SpecAssertion(section = "6.7.4", id = "tb")
+   public void testNonexistentConversationExceptionThrown() throws Exception
+   {
+      WebClient client = new WebClient();
+      HtmlPage page = client.getPage(getPath("/cumulus.jsf?cid=foo"));
+      
+      assert page.getBody().getTextContent().contains("NonexistentConversationException thrown properly");
+      assert page.getBody().getTextContent().contains("Conversation.isTransient: true");
+   }
+   
    @Test
    @SpecAssertions({
       @SpecAssertion(section = "6.7.5", id = "m"),

Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/OutermostFilter.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/OutermostFilter.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/conversation/OutermostFilter.java	2010-02-25 09:40:05 UTC (rev 5960)
@@ -0,0 +1,77 @@
+/*
+ * 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 javax.enterprise.context.Conversation;
+import javax.enterprise.context.NonexistentConversationException;
+import javax.inject.Inject;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+public class OutermostFilter implements Filter
+{
+   @Inject 
+   private Conversation conversation;
+   
+
+   public void destroy()
+   {
+   }
+
+   public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
+   {
+      if ("foo".equals(request.getParameter("cid")))
+      {
+         try
+         {
+            chain.doFilter(request, response);
+            throw new RuntimeException("Expected exception not thrown");
+         }
+         catch (ServletException e)
+         {
+            Throwable cause = e.getCause();
+            while (cause != null)
+            {
+               if (e.getCause() instanceof NonexistentConversationException)
+               {
+                  response.setContentType("text/html");
+                  response.getWriter().print("NonexistentConversationException thrown properly\n");
+                  response.getWriter().print("Conversation.isTransient: " + conversation.isTransient());
+                  return;
+               }
+               cause = e.getCause();
+            }
+            throw new RuntimeException("Unexpected exception thrown");
+         }
+      }
+      else
+      {
+         chain.doFilter(request, response);
+      }
+   }
+
+   public void init(FilterConfig filterConfig) throws ServletException
+   {
+   }
+
+}

Modified: cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml
===================================================================
--- cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml	2010-02-24 03:53:20 UTC (rev 5959)
+++ cdi-tck/trunk/impl/src/main/resources/org/jboss/jsr299/tck/tests/context/conversation/web.xml	2010-02-25 09:40:05 UTC (rev 5960)
@@ -14,6 +14,16 @@
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
    </servlet>
+   
+   <filter>
+      <filter-name>OutermostFilter</filter-name>
+      <filter-class>org.jboss.jsr299.tck.tests.context.conversation.OutermostFilter</filter-class>
+    </filter>
+    
+	<filter-mapping>
+		<filter-name>OutermostFilter</filter-name>
+		<url-pattern>*.jsf</url-pattern>
+	</filter-mapping>
 
    <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>



More information about the weld-commits mailing list