[webbeans-commits] Webbeans SVN: r1154 - tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Jan 21 19:59:14 EST 2009


Author: shane.bryzak at jboss.com
Date: 2009-01-21 19:59:13 -0500 (Wed, 21 Jan 2009)
New Revision: 1154

Added:
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/OtherSpiderProducer.java
Modified:
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/DependentContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Fox.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Spider.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/SpiderProducer.java
   tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Tarantula.java
Log:
dependent context tests

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/DependentContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/DependentContextTest.java	2009-01-22 00:26:48 UTC (rev 1153)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/DependentContextTest.java	2009-01-22 00:59:13 UTC (rev 1154)
@@ -1,5 +1,6 @@
 package org.jboss.webbeans.tck.unit.context.dependent;
 
+import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Set;
 
@@ -16,13 +17,12 @@
 @SpecVersion("20081206")
 public class DependentContextTest extends AbstractTest
 {
-
    /**
-    * No injected instance of the Web Bean is ever shared between multiple
+    * No injected instance of the (@Dependent-scoped) Web Bean is ever shared between multiple
     * injection points.
     */
    @Test(groups = { "contexts", "injection" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testInstanceNotSharedBetweenInjectionPoints()
    {
       deployBeans(Fox.class, FoxRun.class);
@@ -38,23 +38,36 @@
    }
 
    /**
-    * Any instance of the Web Bean that is used to evaluate a Unified EL
+    * Any instance of the (@Dependent-scoped) Web Bean that is used to evaluate a Unified EL
     * expression exists to service that evaluation only.
     */
-   @Test(groups = { "stub", "contexts", "el" })
-   @SpecAssertion(section = "9.4")
-   public void testInstanceUsedForElEvalutionNotShared()
-   {
-      assert false;
+   @Test(groups = { "contexts", "el" })
+   @SpecAssertion(section = "9.3")
+   public void testInstanceUsedForElEvaluationNotShared() throws Exception
+   {     
+      deployBeans(Fox.class);
+      new RunInDependentContext()
+      {         
+         @Override
+         protected void execute() throws Exception
+         {
+            Set<Bean<Fox>> foxBeans = manager.resolveByType(Fox.class);
+            assert foxBeans.size() == 1;
+            Bean<Fox> foxBean = foxBeans.iterator().next();
+            manager.addBean(foxBean);
+
+            assert !manager.getInstanceByName("fox").equals(manager.getInstanceByName("fox"));         }
+         
+      }.run();      
    }
 
    /**
-    * Any instance of the Web Bean that receives a producer method, producer
+    * Any instance of the (@Dependent-scoped) Web Bean that receives a producer method, producer
     * field, disposal method or observer method invocation exists to service
     * that invocation only
     */
    @Test(groups = { "contexts", "producerMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testInstanceUsedForProducerMethodNotShared() throws Exception
    {
       Bean<SpiderProducer> spiderProducer = createSimpleBean(SpiderProducer.class);
@@ -69,36 +82,44 @@
    }
 
    /**
-    * Any instance of the Web Bean that receives a producer method, producer
+    * Any instance of the (@Dependent-scoped) Web Bean that receives a producer method, producer
     * field, disposal method or observer method invocation exists to service
     * that invocation only
     */
-   @Test(groups = { "contexts", "producerMethod", "stub" })
-   @SpecAssertion(section = "9.4")
+   @Test(groups = { "contexts", "producerMethod" })
+   @SpecAssertion(section = "9.3")
    public void testInstanceUsedForProducerFieldNotShared() throws Exception
    {
-      assert false;
+      Bean<OtherSpiderProducer> spiderProducer = createSimpleBean(OtherSpiderProducer.class);
+      manager.addBean(spiderProducer);
+      Field field = OtherSpiderProducer.class.getField("produceTarantula");
+      Bean<Tarantula> tarantulaBean = createProducerFieldBean(field, spiderProducer);
+      Tarantula tarantula = tarantulaBean.create();
+      Tarantula tarantula2 = tarantulaBean.create();
+      assert tarantula != null;
+      assert tarantula2 != null;
+      assert tarantula != tarantula2;
    }
 
    /**
-    * Any instance of the Web Bean that receives a producer method, producer
+    * Any instance of the (@Dependent-scoped) Web Bean that receives a producer method, producer
     * field, disposal method or observer method invocation exists to service
     * that invocation only
     */
    @Test(groups = { "stub", "contexts", "disposalMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testInstanceUsedForDisposalMethodNotShared()
    {
       assert false;
    }
 
    /**
-    * Any instance of the Web Bean that receives a producer method, producer
+    * Any instance of the (@Dependent-scoped) Web Bean that receives a producer method, producer
     * field, disposal method or observer method invocation exists to service
     * that invocation only
     */
    @Test(groups = { "stub", "contexts", "observerMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testInstanceUsedForObserverMethodNotShared()
    {
       assert false;
@@ -110,7 +131,7 @@
     * of the given Web Bean
     */
    @Test(groups = "contexts")
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextGetWithCreateTrueReturnsNewInstance() throws Exception 
    {
       deployBeans(Fox.class);
@@ -129,7 +150,6 @@
          }
          
       }.run();
-      
    }
 
    /**
@@ -137,7 +157,7 @@
     * scope with the value false for the create parameter returns a null value
     */
    @Test(groups = "contexts")
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextGetWithCreateFalseReturnsNull() throws Exception
    {
       deployBeans(Fox.class);
@@ -155,18 +175,16 @@
          }
          
       }.run();
-      
-      
    }
 
    /**
     * The @Dependent scope is inactive except:
     */
    @Test(groups = {"contexts"}, expectedExceptions = ContextNotActiveException.class)
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsInactive()
    {
-      manager.getContext(Dependent.class).isActive();
+      assert !manager.getContext(Dependent.class).isActive();
    }
 
    /**
@@ -175,7 +193,7 @@
     * or observer method invocation, or
     */
    @Test(groups = { "stub", "contexts", "producerMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveWhenInvokingProducerMethod()
    {
       assert false;
@@ -187,10 +205,11 @@
     * or observer method invocation, or
     */
    @Test(groups = { "stub", "contexts", "producerField" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveWhenInvokingProducerField()
    {
       assert false;
+      //assert manager.getContext(Dependent.class).isActive();
    }
 
    /**
@@ -199,7 +218,7 @@
     * or observer method invocation, or
     */
    @Test(groups = { "stub", "contexts", "disposalMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveWhenInvokingDisposalMethod()
    {
       assert false;
@@ -211,7 +230,7 @@
     * or observer method invocation, or
     */
    @Test(groups = { "stub", "contexts", "observerMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveWhenInvokingObserverMethod()
    {
       assert false;
@@ -221,7 +240,7 @@
     * while a Unified EL expression is evaluated, or
     */
    @Test(groups = { "stub", "contexts", "el" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveWhenEvaluatingElExpression()
    {
       assert false;
@@ -232,7 +251,7 @@
     * injecting its dependencies, or
     */
    @Test(groups = { "contexts", "beanLifecycle" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveDuringBeanCreation()
    {
       // Slightly roundabout, but I can't see a better way to test atm
@@ -248,7 +267,7 @@
     * injecting its dependencies, or
     */
    @Test(groups = { "stub", "contexts", "beanDestruction" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveDuringBeanDestruction()
    {
       assert false;
@@ -275,7 +294,7 @@
     * invoked by the EJB container
     */
    @Test(groups = { "contexts", "injection", "stub", "ejb3" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveDuringEJBDependencyInjection()
    {
       assert false;
@@ -287,7 +306,7 @@
     * invoked by the EJB container
     */
    @Test(groups = { "contexts", "injection", "stub", "servlet" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveDuringServletDependencyInjection()
    {
       assert false;
@@ -299,7 +318,7 @@
     * invoked by the EJB container
     */
    @Test(groups = { "contexts", "postconstruct", "stub", "ejb3" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveDuringEJBPostConstruct()
    {
       assert false;
@@ -311,7 +330,7 @@
     * invoked by the EJB container
     */
    @Test(groups = { "contexts", "predestroy", "stub", "ejb3" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testContextIsActiveDuringEJBPreDestroy()
    {
       assert false;
@@ -325,7 +344,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "constructor" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromConstructor()
    {
       assert false;
@@ -339,7 +358,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "removeMethod" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromRemoveMethod()
    {
       assert false;
@@ -353,7 +372,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "initalizerMethod" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromInitializerMethod()
    {
       assert false;
@@ -367,7 +386,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "producerMethod" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromProducerMethod()
    {
       assert false;
@@ -381,7 +400,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "disposalMethod" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromDisposalMethod()
    {
       assert false;
@@ -395,7 +414,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "preDestroy" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromPreDestroy()
    {
       assert false;
@@ -409,7 +428,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "postConstruct" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromPostConstruct()
    {
       assert false;
@@ -423,7 +442,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "interceptor" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromInterceptorOfActiveMethod()
    {
       assert false;
@@ -437,7 +456,7 @@
     * from Web Beans interceptors or decorators for any of these methods
     */
    @Test(groups = { "stub", "contexts", "decorator" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testWebBeanMayCreateInstanceFromDecoratorOfActiveMethod()
    {
       assert false;
@@ -450,7 +469,7 @@
     * methods.
     */
    @Test(groups = { "stub", "contexts", "ejb3", "initializerMethod" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testEjbBeanMayCreateInstanceFromInitializer()
    {
       assert false;
@@ -463,7 +482,7 @@
     * methods.
     */
    @Test(groups = { "stub", "contexts", "ejb3", "postConstruct" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testEjbBeanMayCreateInstanceFromPostConstruct()
    {
       assert false;
@@ -476,7 +495,7 @@
     * methods.
     */
    @Test(groups = { "stub", "contexts", "ejb3", "preDestroy" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testEjbBeanMayCreateInstanceFromPreDestroy()
    {
       assert false;
@@ -489,7 +508,7 @@
     * methods.
     */
    @Test(groups = { "stub", "contexts", "ejb3", "interceptor" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testEjbBeanMayCreateInstanceFromInterceptorOfActiveMethod()
    {
       assert false;
@@ -500,7 +519,7 @@
     * by calling Manager.getInstance() from initializer methods
     */
    @Test(groups = { "stub", "contexts", "servlet", "initializerMethod" })
-   @SpecAssertion(section = "9.4.1")
+   @SpecAssertion(section = "9.3.1")
    public void testServletBeanMayCreateInstanceFromInitializer()
    {
       assert false;
@@ -511,7 +530,7 @@
     * destroyed,
     */
    @Test(groups = { "stub", "contexts", "beanDestruction" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDestroyingParentDestroysDependents()
    {
       assert false;
@@ -522,7 +541,7 @@
     * or Servlet is destroyed,
     */
    @Test(groups = { "stub", "contexts", "ejb3" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDestroyingEjbDestroysDependents()
    {
       assert false;
@@ -533,7 +552,7 @@
     * or Servlet is destroyed,
     */
    @Test(groups = { "stub", "contexts", "servlet" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDestroyingServletDestroysDependents()
    {
       assert false;
@@ -544,7 +563,7 @@
     * expression evaluation when the evaluation completes, and
     */
    @Test(groups = { "stub", "contexts", "el" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDependentsDestroyedWhenElEvaluationCompletes()
    {
       assert false;
@@ -556,7 +575,7 @@
     * invocation when the invocation completes
     */
    @Test(groups = { "stub", "contexts", "producerMethod" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDependentsDestroyedWhenProducerMethodCompletes()
    {
       assert false;
@@ -568,7 +587,7 @@
     * invocation when the invocation completes
     */
    @Test(groups = { "stub", "contexts", "producerField" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDependentsDestroyedWhenProducerFieldCompletes()
    {
       assert false;
@@ -580,7 +599,7 @@
     * invocation when the invocation completes
     */
    @Test(groups = { "stub", "contexts", "disposalMethod" })
-   @SpecAssertion(section = "9.4.2")
+   @SpecAssertion(section = "9.3.2")
    public void testDependentsDestroyedWhenDisposalMethodCompletes()
    {
       assert false;
@@ -592,7 +611,7 @@
     * invocation when the invocation completes
     */
    @Test(groups = { "stub", "contexts", "observerMethod" })
-   @SpecAssertion(section = "9.4")
+   @SpecAssertion(section = "9.3")
    public void testDependentsDestroyedWhenObserverMethodEvaluationCompletes()
    {
       assert false;

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Fox.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Fox.java	2009-01-22 00:26:48 UTC (rev 1153)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Fox.java	2009-01-22 00:59:13 UTC (rev 1154)
@@ -1,8 +1,9 @@
 package org.jboss.webbeans.tck.unit.context.dependent;
 
 import javax.webbeans.Dependent;
+import javax.webbeans.Named;
 
- at Dependent
+ at Dependent @Named
 class Fox
 {
    

Added: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/OtherSpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/OtherSpiderProducer.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/OtherSpiderProducer.java	2009-01-22 00:59:13 UTC (rev 1154)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.tck.unit.context.dependent;
+
+import javax.webbeans.Produces;
+
+ at AnotherDeploymentType
+public class OtherSpiderProducer
+{
+   @Produces public Tarantula produceTarantula = new Tarantula();
+}

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Spider.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Spider.java	2009-01-22 00:26:48 UTC (rev 1153)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Spider.java	2009-01-22 00:59:13 UTC (rev 1154)
@@ -1,13 +1,9 @@
 package org.jboss.webbeans.tck.unit.context.dependent;
 
-
-
 class Spider implements Animal
 {
-
    public final void layEggs()
    {
       
-   }
-   
+   }   
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/SpiderProducer.java	2009-01-22 00:26:48 UTC (rev 1153)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/SpiderProducer.java	2009-01-22 00:59:13 UTC (rev 1154)
@@ -1,15 +1,18 @@
 package org.jboss.webbeans.tck.unit.context.dependent;
 
+import javax.webbeans.Disposes;
 import javax.webbeans.Produces;
 
-
 @AnotherDeploymentType
 class SpiderProducer
 {
-   
    @Produces public Tarantula produceTarantula()
    {
       return new Tarantula();
    }
-   
+
+   public void disposeTarantula(@Disposes Tarantula tarantula)
+   {
+      
+   }
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Tarantula.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Tarantula.java	2009-01-22 00:26:48 UTC (rev 1153)
+++ tck/trunk/impl/src/main/java/org/jboss/webbeans/tck/unit/context/dependent/Tarantula.java	2009-01-22 00:59:13 UTC (rev 1154)
@@ -1,6 +1,5 @@
 package org.jboss.webbeans.tck.unit.context.dependent;
 
-
 class Tarantula extends Spider implements DeadlySpider
 {
 




More information about the weld-commits mailing list