[webbeans-commits] Webbeans SVN: r2100 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests: context/dependent and 5 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Wed Mar 18 17:28:19 EDT 2009


Author: dallen6
Date: 2009-03-18 17:28:19 -0400 (Wed, 18 Mar 2009)
New Revision: 2100

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/Tuna.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/TunaFarm.java
Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/DisposalMethodDefinitionTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
Log:
Additional tests and assertion assignments

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/NormalContextTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -6,20 +6,19 @@
 import javax.context.SessionScoped;
 
 import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
 import org.jboss.jsr299.tck.AbstractJSR299Test;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.testng.annotations.Test;
 
 /**
+ * This class tests a basic context against section 8 of the specification 
  * 
+ * Spec version: PRD2
+ * 
  * @author Nicklas Karlsson
  * @author Pete Muir
  * @author David Allen
- * 
- *         This class tests a basic context against section 8 of the
- *         specification
- * 
- *         Spec version: PRD2
  */
 @Artifact
 public class NormalContextTest extends AbstractJSR299Test
@@ -50,7 +49,9 @@
    }
 
    @Test(groups = { "contexts" })
-   @SpecAssertion(section = "8.1", id = "c")
+   @SpecAssertions( { 
+      @SpecAssertion(section = "8.1", id = "c")
+   } )
    public void testGetWithCreationalContextReturnsNewInstance()
    {
       initContext();
@@ -58,8 +59,9 @@
       bean.setShouldReturnNullInstances(false);
       getCurrentManager().addBean(bean);
 
-      CreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
-      assert getCurrentManager().getContext(SessionScoped.class).get(bean, myCreationalContext) != null;
+      MyCreationalContext<MySessionBean> myCreationalContext = new MyCreationalContext<MySessionBean>();
+      MySessionBean newBean = getCurrentManager().getContext(SessionScoped.class).get(bean, myCreationalContext);
+      assert newBean != null;
       assert bean.isCreateCalled();
    }
 
@@ -80,7 +82,11 @@
    }
 
    @Test(groups = { "contexts" })
-   @SpecAssertion(section = "8.1", id = "f")
+   @SpecAssertions( { 
+      @SpecAssertion(section = "6", id = "i"),
+      @SpecAssertion(section = "6", id = "j"),
+      @SpecAssertion(section = "8.1", id = "f")
+   })
    public void testContextDestroysBeansWhenDestroyed()
    {
       initContext();

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/dependent/DependentContextTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -82,28 +82,26 @@
       assert tarantula != tarantula2;
    }
 
-   @Test(groups = { "broken", "contexts", "disposalMethod" })
+   @Test(groups = { "contexts", "disposalMethod", "ri-broken" })
    @SpecAssertion(section = "8.3", id = "d")
    public void testInstanceUsedForDisposalMethodNotShared() throws Exception
    {
-//      deployBeans(SpiderProducer.class);
-//      new RunInDependentContext()
-//      {
-//
-//         @Override
-//         protected void execute() throws Exception
-//         {
-//            SpiderProducer spiderProducer = getCurrentManager().getInstanceByType(SpiderProducer.class);
-//            Bean<Tarantula> tarantulaBean = getCurrentManager().resolveByType(Tarantula.class).iterator().next();
-//            Tarantula tarantula = tarantulaBean.create(new MyCreationalContext<Tarantula>());
-//            assert tarantula != null;
-//            tarantulaBean.destroy(tarantula);
-//            assert SpiderProducer.getInstanceUsedForDisposal() != null;
-//            assert SpiderProducer.getInstanceUsedForDisposal() != spiderProducer;
-//         }
-//
-//      }.run();
-      assert false;
+      new RunInDependentContext()
+      {
+
+         @Override
+         protected void execute() throws Exception
+         {
+            SpiderProducer spiderProducer = getCurrentManager().getInstanceByType(SpiderProducer.class);
+            Bean<Tarantula> tarantulaBean = getCurrentManager().resolveByType(Tarantula.class).iterator().next();
+            Tarantula tarantula = getCurrentManager().getInstanceByType(Tarantula.class);
+            assert tarantula != null;
+            tarantulaBean.destroy(tarantula);
+            assert SpiderProducer.getInstanceUsedForDisposal() != null;
+            assert SpiderProducer.getInstanceUsedForDisposal() != spiderProducer;
+         }
+
+      }.run();
    }
 
    @Test(groups = { "contexts", "observerMethod" })

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/lifecycle/EnterpriseBeanLifecycleTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -45,7 +45,10 @@
     * bean proxy, as defined in Section 3.3.9, "Session bean proxies".
     */
    @Test(groups = { "enterpriseBeans", "clientProxy", "lifecycle", "integration" })
-   @SpecAssertions( { @SpecAssertion(section = "3.3.8", id = "a"), @SpecAssertion(section = "6.5", id = "a") })
+   @SpecAssertions( { 
+      @SpecAssertion(section = "3.3.8", id = "a"), 
+      @SpecAssertion(section = "6", id = "a"),
+      @SpecAssertion(section = "6.5", id = "a") })
    public void testCreateSFSB()
    {
       GrossStadt frankfurt = getCurrentManager().getInstanceByType(GrossStadt.class);

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/DisposalMethodDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/DisposalMethodDefinitionTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/disposal/definition/DisposalMethodDefinitionTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -24,7 +24,7 @@
       @SpecAssertion(section = "3.4.6", id = "a"),
       @SpecAssertion(section = "3.4.6", id = "c")
    })
-   public void testDisposalMethodCanBeOfSimpleOrSessionBean()
+   public void testDisposalMethodMustBeOnSimpleOrSessionBean()
    {
       assert false;
    }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/ProducerMethodLifecycleTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -28,7 +28,7 @@
       @SpecAssertion(section = "3.4", id = "c"),
       @SpecAssertion(section = "3.4", id = "k"),
       @SpecAssertion(section = "3.4.2", id = "a"),
-      @SpecAssertion(section = "6", id = "a"),
+      @SpecAssertion(section = "6", id = "b"),
       @SpecAssertion(section = "6.7", id = "e")
    })
    public void testProducerMethodBeanCreate() throws Exception
@@ -38,6 +38,28 @@
       assert tarantula.getValue().equals("Pete") : "Producer method not used to create Tarantula";
    }
 
+   @Test(groups = { "producerMethod", "disposalMethod", "ri-broken" })
+   @SpecAssertions({
+      @SpecAssertion(section = "6", id = "f")
+   })
+   public void testProducerMethodBeanDestroy() throws Exception
+   {
+      new RunInDependentContext()
+      {
+
+         @Override
+         protected void execute() throws Exception
+         {
+            SpiderProducer.setTarantulaDestroyed(false);
+            Tarantula tarantula = getCurrentManager().getInstanceByType(Tarantula.class);
+            Bean<Tarantula> tarantulaBean = getCurrentManager().resolveByType(Tarantula.class).iterator().next();
+            tarantulaBean.destroy(tarantula);
+            assert SpiderProducer.isTarantulaDestroyed();
+         }
+         
+      }.run();
+   }
+
    @Test(groups = { "specialization" })
    @SpecAssertions({
       @SpecAssertion(section = "6.7", id = "g"),

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/method/lifecycle/SpiderProducer.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -1,11 +1,13 @@
 package org.jboss.jsr299.tck.tests.implementation.producer.method.lifecycle;
 
+import javax.inject.Disposes;
 import javax.inject.Produces;
 
 @AnotherDeploymentType
 class SpiderProducer
 {
-   
+   private static boolean tarantulaDestroyed;
+
    @Produces public Tarantula produceTarantula()
    {
       return new Tarantula("Pete");
@@ -16,4 +18,18 @@
       return null;
    }
    
+   public void destroyTarantula(@Disposes Tarantula spider)
+   {
+      tarantulaDestroyed = true;
+   }
+
+   public static boolean isTarantulaDestroyed()
+   {
+      return tarantulaDestroyed;
+   }
+
+   public static void setTarantulaDestroyed(boolean tarantulaDestroyed)
+   {
+      SpiderProducer.tarantulaDestroyed = tarantulaDestroyed;
+   }
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -2,6 +2,8 @@
 
 import java.lang.annotation.Annotation;
 
+import javax.context.Context;
+import javax.context.RequestScoped;
 import javax.inject.AnnotationLiteral;
 import javax.inject.CreationException;
 import javax.inject.manager.Bean;
@@ -130,6 +132,19 @@
       assert tunaFarm.tuna != null;
    }
 
+   @Test(groups = "beanLifecycle")
+   @SpecAssertions({
+      @SpecAssertion(section = "6", id = "g")
+   })
+   public void testContextCreatesNewInstanceForInjection()
+   {
+      Context requestContext = getCurrentManager().getContext(RequestScoped.class);
+      Bean<Tuna> tunaBean = getCurrentManager().resolveByType(Tuna.class).iterator().next();
+      assert requestContext.get(tunaBean) == null;
+      TunaFarm tunaFarm = getCurrentManager().getInstanceByType(TunaFarm.class);
+      assert tunaFarm.tuna != null;
+   }
+
    @Test(groups = { "beanLifecycle", "lifecycleCallbacks" })
    @SpecAssertions({
      @SpecAssertion(section = "6.2", id = "f"),

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java	2009-03-18 21:27:44 UTC (rev 2099)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/ResolutionByNameTest.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -1,8 +1,12 @@
 package org.jboss.jsr299.tck.tests.lookup.el;
 
+import javax.context.Context;
 import javax.context.Conversation;
+import javax.context.RequestScoped;
+import javax.inject.manager.Bean;
 
 import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
 import org.jboss.jsr299.tck.AbstractJSR299Test;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.testng.annotations.Test;
@@ -35,4 +39,18 @@
       assert getCurrentConfiguration().getEl().evaluateValueExpression("#{javax.context.conversation}", Conversation.class) != null;
       assert getCurrentConfiguration().getEl().evaluateValueExpression("#{javax.context.conversation}", Conversation.class) instanceof Conversation;
    }
+
+   @Test(groups = "beanLifecycle")
+   @SpecAssertions({
+      @SpecAssertion(section = "6", id = "h")
+   })
+   public void testContextCreatesNewInstanceForInjection()
+   {
+      Context requestContext = getCurrentManager().getContext(RequestScoped.class);
+      Bean<Tuna> tunaBean = getCurrentManager().resolveByType(Tuna.class).iterator().next();
+      assert requestContext.get(tunaBean) == null;
+      TunaFarm tunaFarm = getCurrentConfiguration().getEl().evaluateValueExpression("#{tunaFarm}", TunaFarm.class);
+      assert tunaFarm.tuna != null;
+   }
+
 }

Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/Tuna.java (from rev 2092, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/Tuna.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/Tuna.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/Tuna.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -0,0 +1,14 @@
+package org.jboss.jsr299.tck.tests.lookup.el;
+
+import javax.context.RequestScoped;
+
+ at RequestScoped
+class Tuna
+{
+   
+   public String getName()
+   {
+      return "Ophir";
+   }
+
+}

Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/TunaFarm.java (from rev 2092, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/TunaFarm.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/TunaFarm.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/el/TunaFarm.java	2009-03-18 21:28:19 UTC (rev 2100)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.lookup.el;
+
+import javax.annotation.Named;
+import javax.inject.Current;
+
+ at Named
+class TunaFarm
+{
+
+   @SuppressWarnings("unused")
+   @Current
+   public Tuna tuna;
+   
+   public Tuna notInjectedTuna = new Tuna();
+
+   
+}




More information about the weld-commits mailing list