[weld-commits] Weld SVN: r6046 - in core/trunk: tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation and 1 other directories.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Mar 14 19:05:03 EDT 2010


Author: nickarls
Date: 2010-03-14 19:05:02 -0400 (Sun, 14 Mar 2010)
New Revision: 6046

Modified:
   core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
   core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java
   core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf
Log:
WELD-461

Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java	2010-03-14 09:13:00 UTC (rev 6045)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java	2010-03-14 23:05:02 UTC (rev 6046)
@@ -195,6 +195,10 @@
    
    private void teardownContext(AbstractThreadLocalMapContext context)
    {
+	  if (context.getBeanStore() == null) 
+	  {
+		  return;
+	  }
       context.setActive(true);
       context.destroy();
       context.setBeanStore(null);

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java	2010-03-14 09:13:00 UTC (rev 6045)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/InvalidateSessionTest.java	2010-03-14 23:05:02 UTC (rev 6046)
@@ -17,6 +17,8 @@
 
 package org.jboss.weld.tests.contexts.sessionInvalidation;
 
+import java.io.IOException;
+import java.net.MalformedURLException;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -29,6 +31,7 @@
 import org.jboss.weld.test.AbstractWeldTest;
 import org.testng.annotations.Test;
 
+import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
 import com.gargoylesoftware.htmlunit.WebClient;
 import com.gargoylesoftware.htmlunit.html.HtmlElement;
 import com.gargoylesoftware.htmlunit.html.HtmlInput;
@@ -70,6 +73,15 @@
       assert SomeBean.DEFAULT_PROPERTY_VALUE.equals(inputField.getValueAttribute());
    }
 
+   @Test(description="WELD-461")
+   public void testNoDoubleDestructionOnExternalRedirect() throws Exception
+   {
+	   WebClient client = new WebClient();
+	   HtmlPage page = client.getPage(getPath("/storm.jsf"));
+	   HtmlSubmitInput button = getFirstMatchingElement(page, HtmlSubmitInput.class, "redirectButton");
+	   button.click();
+   }
+   
    protected <T> Set<T> getElements(HtmlElement rootElement, Class<T> elementClass)
    {
      Set<T> result = new HashSet<T>();

Modified: core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java	2010-03-14 09:13:00 UTC (rev 6045)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/contexts/sessionInvalidation/Storm.java	2010-03-14 23:05:02 UTC (rev 6046)
@@ -16,6 +16,9 @@
  */
 package org.jboss.weld.tests.contexts.sessionInvalidation;
 
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 import javax.inject.Named;
 
@@ -37,5 +40,7 @@
       return "success";
    }
    
-   
+   public void redirect() throws IOException {
+	   FacesContext.getCurrentInstance().getExternalContext().redirect("storm.jsf");
+   }
 }

Modified: core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf	2010-03-14 09:13:00 UTC (rev 6045)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/contexts/sessionInvalidation/storm.jsf	2010-03-14 23:05:02 UTC (rev 6046)
@@ -22,6 +22,7 @@
       <hr/>
       <h:form id="form">
          <h:commandButton action="#{storm.invalidateSession}" value="Invalidate Session" id="invalidateSessionButton"/>
+         <h:commandButton action="#{storm.redirect}" value="Invalidate Session" id="redirectButton"/>
       </h:form>
    </f:view>
   </body>



More information about the weld-commits mailing list