[weld-commits] Weld SVN: r4178 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Sun Oct 18 08:44:57 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-10-18 08:44:56 -0400 (Sun, 18 Oct 2009)
New Revision: 4178

Added:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextDestroysBeansTest.java
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContext2Test.java
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContextTest.java
Modified:
   cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
Log:
Don't expect to be able to reuse a destroyed context in the same test

Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextDestroysBeansTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextDestroysBeansTest.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextDestroysBeansTest.java	2009-10-18 12:44:56 UTC (rev 4178)
@@ -0,0 +1,48 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
+
+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
+ * @author Pete Muir
+ * @author David Allen
+ */
+ at Artifact
+ at SpecVersion(spec="cdi", version="PFD2")
+public class ContextDestroysBeansTest extends AbstractJSR299Test
+{
+
+   @Test(groups = { "contexts", "rewrite" })
+   @SpecAssertions( {
+      @SpecAssertion(section = "6.2", id = "p"),
+      @SpecAssertion(section = "6.3", id = "d")
+   })
+   public void testContextDestroysBeansWhenDestroyed()
+   {
+      MyContextual bean = new MyContextual(getCurrentManager());
+      bean.setShouldReturnNullInstances(false);
+      // TODO Remove use of this deprecated API
+      getCurrentManager().addBean(bean);
+
+      Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
+      CreationalContext<MySessionBean> creationalContext = getCurrentManager().createCreationalContext(bean);
+      MySessionBean instance = sessionContext.get(bean, creationalContext);
+      instance.ping();
+      assert instance != null;
+      assert bean.isCreateCalled();
+      
+      destroyContext(sessionContext);
+      assert bean.isDestroyCalled();
+   }
+   
+}
\ No newline at end of file


Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/ContextDestroysBeansTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContext2Test.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContext2Test.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContext2Test.java	2009-10-18 12:44:56 UTC (rev 4178)
@@ -0,0 +1,55 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+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
+ * @author Pete Muir
+ * @author David Allen
+ */
+ at Artifact
+ at SpecVersion(spec="cdi", version="PFD2")
+public class DestroyForSameCreationalContext2Test extends AbstractJSR299Test
+{
+   
+   @Test
+   @SpecAssertion(section = "6.2", id = "r")
+   public void testDestroyForSameCreationalContextOnly()
+   {
+      // Check that the mock cc is called (via cc.release()) when we request a context destroyed
+      // Note that this is an indirect effect
+      Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
+      Context requestContext = getCurrentManager().getContext(RequestScoped.class);
+      Context appContext = getCurrentManager().getContext(ApplicationScoped.class);
+      
+      // We also test this directly using a custom contextual, and ensuring that the same contextual is passed to both methods
+      DummyContextual contextual = new DummyContextual();
+      
+      sessionContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
+      destroyContext(sessionContext);
+      assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
+      
+      // Do it for other contexts
+      contextual = new DummyContextual();
+      appContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
+      destroyContext(appContext);
+      assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
+      
+      contextual = new DummyContextual();
+      requestContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
+      destroyContext(requestContext);
+      assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
+      
+   }
+   
+}


Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContext2Test.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Added: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContextTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContextTest.java	                        (rev 0)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContextTest.java	2009-10-18 12:44:56 UTC (rev 4178)
@@ -0,0 +1,46 @@
+package org.jboss.jsr299.tck.tests.context;
+
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.impl.MockCreationalContext;
+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
+ * @author Pete Muir
+ * @author David Allen
+ */
+ at Artifact
+ at SpecVersion(spec="cdi", version="PFD2")
+public class DestroyForSameCreationalContextTest extends AbstractJSR299Test
+{
+   
+   @Test
+   @SpecAssertion(section = "6.2", id = "r")
+   public void testDestroyForSameCreationalContextOnly()
+   {
+      // Check that the mock cc is called (via cc.release()) when we request a context destroyed
+      // Note that this is an indirect effect
+      Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
+      
+      Bean<AnotherSessionBean> sessionBean = getBeans(AnotherSessionBean.class).iterator().next();
+      
+      MockCreationalContext.reset();
+      CreationalContext<AnotherSessionBean> creationalContext = new MockCreationalContext<AnotherSessionBean>();
+      AnotherSessionBean instance = sessionContext.get(sessionBean, creationalContext);
+      instance.ping();
+      
+      destroyContext(sessionContext);
+      assert MockCreationalContext.isReleaseCalled();
+            
+   }
+   
+}


Property changes on: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/DestroyForSameCreationalContextTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:eol-style
   + native

Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java	2009-10-18 12:43:37 UTC (rev 4177)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java	2009-10-18 12:44:56 UTC (rev 4178)
@@ -1,9 +1,6 @@
 package org.jboss.jsr299.tck.tests.context;
 
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.RequestScoped;
 import javax.enterprise.context.SessionScoped;
-import javax.enterprise.context.spi.Context;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.spi.Bean;
 
@@ -78,70 +75,7 @@
       assert getCurrentManager().getContext(SessionScoped.class).get(bean, creationalContext) == null;
       assert bean.isCreateCalled();
    }
-
-   @Test(groups = { "contexts", "rewrite" })
-   @SpecAssertions( {
-      @SpecAssertion(section = "6.2", id = "p"),
-      @SpecAssertion(section = "6.3", id = "d")
-   })
-   public void testContextDestroysBeansWhenDestroyed()
-   {
-      MyContextual bean = new MyContextual(getCurrentManager());
-      bean.setShouldReturnNullInstances(false);
-      // TODO Remove use of this deprecated API
-      getCurrentManager().addBean(bean);
-
-      Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
-      CreationalContext<MySessionBean> creationalContext = getCurrentManager().createCreationalContext(bean);
-      MySessionBean instance = sessionContext.get(bean, creationalContext);
-      instance.ping();
-      assert instance != null;
-      assert bean.isCreateCalled();
-      
-      destroyContext(sessionContext);
-      assert bean.isDestroyCalled();
-   }
    
-   @Test
-   @SpecAssertion(section = "6.2", id = "r")
-   public void testDestroyForSameCreationalContextOnly()
-   {
-      // Check that the mock cc is called (via cc.release()) when we request a context destroyed
-      // Note that this is an indirect effect
-      Context sessionContext = getCurrentManager().getContext(SessionScoped.class);
-      Context requestContext = getCurrentManager().getContext(RequestScoped.class);
-      Context appContext = getCurrentManager().getContext(ApplicationScoped.class);
-      
-      Bean<AnotherSessionBean> sessionBean = getBeans(AnotherSessionBean.class).iterator().next();
-      
-      MockCreationalContext.reset();
-      CreationalContext<AnotherSessionBean> creationalContext = new MockCreationalContext<AnotherSessionBean>();
-      AnotherSessionBean instance = sessionContext.get(sessionBean, creationalContext);
-      instance.ping();
-      
-      destroyContext(sessionContext);
-      assert MockCreationalContext.isReleaseCalled();
-      
-      // We also test this directly using a custom contextual, and ensuring that the same contextual is passed to both methods
-      DummyContextual contextual = new DummyContextual();
-      
-      sessionContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
-      destroyContext(sessionContext);
-      assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
-      
-      // Do it for other contexts
-      contextual = new DummyContextual();
-      appContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
-      destroyContext(appContext);
-      assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
-      
-      contextual = new DummyContextual();
-      requestContext.get(contextual, getCurrentManager().createCreationalContext(contextual));
-      destroyContext(requestContext);
-      assert contextual.getCreationalContextPassedToCreate() == contextual.getCreationalContextPassedToDestroy();
-      
-   }
-   
    @Test(groups = { "contexts" })
    @SpecAssertions( {
       @SpecAssertion(section = "6.3", id = "e")



More information about the weld-commits mailing list