[webbeans-commits] Webbeans SVN: r1476 - in tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit: lookup/byname and 1 other directory.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Tue Feb 10 13:26:57 EST 2009


Author: dallen6
Date: 2009-02-10 13:26:57 -0500 (Tue, 10 Feb 2009)
New Revision: 1476

Added:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/CowDung.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/HorseDung.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/DuplicateNameResolutionTest.java
Modified:
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractCow.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractHorse.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/RealizationTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/InstantiationByNameTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/ResolutionByNameTest.java
Log:
New tests and a few old ones broken.

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractCow.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractCow.java	2009-02-10 08:00:12 UTC (rev 1475)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractCow.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -6,9 +6,9 @@
 abstract class AbstractCow
 {
    
-   @Produces @RequestScoped @Smelly @FarmAnimalDeploymentType Dung getDung()
+   @Produces @RequestScoped @Smelly @FarmAnimalDeploymentType CowDung getDung()
    {
-      return new Dung();
+      return new CowDung();
    }
    
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractHorse.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractHorse.java	2009-02-10 08:00:12 UTC (rev 1475)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/AbstractHorse.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -6,6 +6,6 @@
 abstract class AbstractHorse
 {
    
-   @Produces @Smelly @RequestScoped @FarmAnimalDeploymentType private Dung dung = new Dung();
+   @Produces @Smelly @RequestScoped @FarmAnimalDeploymentType private HorseDung dung = new HorseDung();
    
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/CowDung.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/CowDung.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/CowDung.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.unit.inheritance.realization;
+
+class CowDung extends Dung
+{
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/CowDung.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/HorseDung.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/HorseDung.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/HorseDung.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.unit.inheritance.realization;
+
+class HorseDung extends Dung
+{
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/HorseDung.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/RealizationTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/RealizationTest.java	2009-02-10 08:00:12 UTC (rev 1475)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/inheritance/realization/RealizationTest.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -11,18 +11,25 @@
 
 import org.jboss.jsr299.tck.AbstractTest;
 import org.jboss.jsr299.tck.SpecAssertion;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
 import org.testng.annotations.Test;
 
 /**
  * 
  * Spec version: PRD2
- *
+ * 
  */
+ at Artifact
 public class RealizationTest extends AbstractTest
 {
-   
-   private static Annotation SMELLY_LITERAL = new AnnotationLiteral<Smelly>(){}; 
-      
+
+   private static Annotation SMELLY_LITERAL = new AnnotationLiteral<Smelly>()
+   {
+   };
+   private static Annotation TAME_LITERAL = new AnnotationLiteral<Tame>()
+   {
+   };
+
    @Override
    protected List<Class<? extends Annotation>> getEnabledDeploymentTypes()
    {
@@ -32,121 +39,140 @@
       deploymentTypes.add(FarmAnimalDeploymentType.class);
       return deploymentTypes;
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerMethodHasSameScope()
    {
-      deployBeans(Cow.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getScopeType().equals(RequestScoped.class);
+      // deployBeans(Cow.class);
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).iterator().next().getScopeType().equals(RequestScoped.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerMethodHasDeploymentTypeOfRealizingClass()
    {
-      deployBeans(Cow.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getDeploymentType().equals(AnotherDeploymentType.class);
+      // deployBeans(Cow.class);
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).iterator().next().getDeploymentType().equals(AnotherDeploymentType.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerMethodHasSameBindings()
    {
-      deployBeans(Cow.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings().iterator().next().annotationType().equals(Smelly.class);
+      // deployBeans(Cow.class);
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 1;
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL).iterator().next().getBindings().iterator().next().annotationType().equals(Smelly.class);
    }
-   
-   @Test at SpecAssertion(section="4.4", id = "unknown")
+
+   @SuppressWarnings("unchecked")
+   @Test
+   @SpecAssertion(section = "4.4.1", id = "unknown")
    public void testRealizedBeanWithProducerMethodHasBindingsOfMethodAndRealizingType()
    {
-      deployBeans(TameCow.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 2;
-      assert annotationSetMatches(manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings(), Smelly.class, Tame.class);
+      // deployBeans(TameCow.class);
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL, TAME_LITERAL).size() == 1;
+      assert manager.resolveByType(CowDung.class, SMELLY_LITERAL, TAME_LITERAL).iterator().next().getBindings().size() == 2;
+      assert annotationSetMatches(manager.resolveByType(CowDung.class, SMELLY_LITERAL, TAME_LITERAL).iterator().next().getBindings(), Smelly.class, Tame.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test(groups = "broken")
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerMethodHasSameStereotypes()
    {
-      deployBeans(LabradorKennel.class);
+      // deployBeans(LabradorKennel.class);
       assert manager.resolveByType(Dog.class).size() == 1;
       assert manager.resolveByType(Dog.class).iterator().next().getScopeType().equals(RequestScoped.class);
    }
-   
-   @Test(groups="stub") @SpecAssertion(section="4.1", id = "unknown")
+
+   @Test(groups = "stub")
+   @SpecAssertion(section = "4.1", id = "unknown")
    public void testRealizedBeanWithProducerMethodHasSameInterceptorBindings()
    {
       assert false;
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerFieldHasSameScope()
    {
-      deployBeans(Horse.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getScopeType().equals(RequestScoped.class);
+      // deployBeans(Horse.class);
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).iterator().next().getScopeType().equals(RequestScoped.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerFieldHasDeploymentTypeOfRealizingClass()
    {
-      deployBeans(Horse.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getDeploymentType().equals(AnotherDeploymentType.class);
+      // deployBeans(Horse.class);
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).iterator().next().getDeploymentType().equals(AnotherDeploymentType.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerFieldHasSameBindings()
    {
-      deployBeans(Horse.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings().iterator().next().annotationType().equals(Smelly.class);
+      // deployBeans(Horse.class);
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 1;
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).iterator().next().getBindings().iterator().next().annotationType().equals(Smelly.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @SuppressWarnings("unchecked")
+   @Test(groups = "broken")
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerFieldHasBindingsOfMethodAndRealizingType()
    {
-      deployBeans(TameHorse.class);
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).size() == 1;
-      assert manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 2;
-      assert annotationSetMatches(manager.resolveByType(Dung.class, SMELLY_LITERAL).iterator().next().getBindings(), Smelly.class, Tame.class);
+      // deployBeans(TameHorse.class);
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).size() == 1;
+      assert manager.resolveByType(HorseDung.class, SMELLY_LITERAL).iterator().next().getBindings().size() == 2;
+      assert annotationSetMatches(manager.resolveByType(HorseDung.class, SMELLY_LITERAL).iterator().next().getBindings(), Smelly.class, Tame.class);
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test(groups = "broken")
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerFieldHasSameStereotypes()
    {
-      deployBeans(Stable.class);
+      // deployBeans(Stable.class);
       assert manager.resolveByType(Horse.class).size() == 1;
       assert manager.resolveByType(Horse.class).iterator().next().getScopeType().equals(RequestScoped.class);
    }
-   
-   @Test(groups="stub") @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test(groups = "stub")
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedBeanWithProducerFieldHasSameInterceptorBindings()
    {
       assert false;
    }
-   
-   @Test(groups="stub") @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test(groups = "stub")
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testDisposalMethodInherited()
    {
       assert false;
    }
-   
-   @Test(groups="stub") @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test(groups = "stub")
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testRealizedDisposalMethodHasBindingsOfMethodAndRealizingType()
    {
       assert false;
    }
-   
-   @Test @SpecAssertion(section="4.4", id = "unknown")
+
+   @Test
+   @SpecAssertion(section = "4.4", id = "unknown")
    public void testObserverMethodInheritedAndHasSameBindings()
    {
-      deployBeans(FarmHouse.class);
-      assert manager.resolveObservers(new Cow(), new AnnotationLiteral<Tame>(){}).size() == 1;
+      // deployBeans(FarmHouse.class);
+      assert manager.resolveObservers(new Cow(), new AnnotationLiteral<Tame>()
+      {
+      }).size() == 1;
       assert manager.resolveObservers(new Cow(), SMELLY_LITERAL).size() == 0;
    }
-   
+
 }

Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/DuplicateNameResolutionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/DuplicateNameResolutionTest.java	                        (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/DuplicateNameResolutionTest.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.unit.lookup.byname;
+
+import javax.inject.AmbiguousDependencyException;
+
+import org.jboss.jsr299.tck.AbstractTest;
+import org.jboss.jsr299.tck.SpecAssertion;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
+import org.jboss.jsr299.tck.impl.packaging.Classes;
+import org.testng.annotations.Test;
+
+/**
+ * 
+ * Spec version: Public Release Draft 2
+ * 
+ */
+ at Artifact(addCurrentPackage=false)
+ at Classes(value={Cod.class, Sole.class})
+public class DuplicateNameResolutionTest extends AbstractTest
+{
+   /**
+    * � Otherwise, if resolveByName() returned more than one Web Bean, throw an
+    * AmbiguousDependencyException.
+    * 
+    * @throws Exception
+    */
+   @Test(groups = { "resolution", "el" }, expectedExceptions = AmbiguousDependencyException.class)
+   @SpecAssertion(section = "5.10", id = "unknown")
+   public void testDuplicateNamedBeans() throws Exception
+   {
+      new RunInDependentContext()
+      {
+
+         @Override
+         protected void execute() throws Exception
+         {
+            assert manager.resolveByName("whitefish").size() == 2;
+            manager.getInstanceByName("whitefish");
+         }
+
+      }.run();
+   }
+
+}


Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/DuplicateNameResolutionTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/InstantiationByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/InstantiationByNameTest.java	2009-02-10 08:00:12 UTC (rev 1475)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/InstantiationByNameTest.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -15,62 +15,8 @@
 public class InstantiationByNameTest extends AbstractTest
 {
    
-   @Test(groups="resolution") @SpecAssertion(section="5.10", id = "unknown")
-   public void testNoWebBeansFound() throws Exception
-   {
-      Bean<Cod> codBean = createSimpleBean(Cod.class);
-      Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);
-      manager.addBean(codBean);
-      manager.addBean(salmonBean);
-      
-      assert manager.getInstanceByName("foo") == null;
-   }
-   
-   @Test(expectedExceptions=AmbiguousDependencyException.class) 
-   @SpecAssertion(section="5.7.1", id = "unknown")
-   public void testAmbiguousDependencies() throws Exception
-   {
-      Bean<Cod> codBean = createSimpleBean(Cod.class);
-      Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);
-      Bean<Sole> soleBean = createSimpleBean(Sole.class);
-      manager.addBean(codBean);
-      manager.addBean(salmonBean);
-      manager.addBean(soleBean);
-      
-      manager.getInstanceByName("whitefish");
-   }
-   
-   @Test(groups={"resolution", "beanLifecycle"}) @SpecAssertion(section="5.7.1", id = "unknown")
-   public void testGetInstanceByName()
-   {
-      Bean<Tuna> tunaBean = createSimpleBean(Tuna.class);
-      Bean<Cod> codBean = createSimpleBean(Cod.class);
-      Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);
-      Bean<Sole> soleBean = createSimpleBean(Sole.class);
-      Bean<SeaBass> seaBassBean = createSimpleBean(SeaBass.class);
-      Bean<Haddock> haddockBean = createSimpleBean(Haddock.class);
-      Bean<Plaice> plaiceBean = createSimpleBean(Plaice.class);
-      
-      manager.addBean(tunaBean);
-      manager.addBean(codBean);
-      manager.addBean(salmonBean);
-      manager.addBean(soleBean);
-      manager.addBean(haddockBean);
-      manager.addBean(seaBassBean);
-      manager.addBean(plaiceBean);
-      
-      try
-      {
-         activateDependentContext();
-         assert manager.getInstanceByName("salmon") instanceof Salmon;
-      }
-      finally
-      {
-         deactivateDependentContext();
-      }
-   }
-   
-   @Test(groups={"stub", "resolution", "el"}) @SpecAssertion(section="5.10", id = "unknown")
+   @Test(groups={"underInvestigation", "resolution", "el"}) @SpecAssertion(section="5.10", id = "unknown")
+   //TODO Need to find a way to intercept calls to the manager to verify this condition
    public void testGetInstanceByNameCalledOncePerDistinctNameInElExpression()
    {
       assert false;

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/ResolutionByNameTest.java	2009-02-10 08:00:12 UTC (rev 1475)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/unit/lookup/byname/ResolutionByNameTest.java	2009-02-10 18:26:57 UTC (rev 1476)
@@ -3,21 +3,20 @@
 import java.lang.annotation.Annotation;
 import java.util.List;
 
-import javax.inject.AmbiguousDependencyException;
-import javax.inject.manager.Bean;
-
 import org.jboss.jsr299.tck.AbstractTest;
 import org.jboss.jsr299.tck.SpecAssertion;
+import org.jboss.jsr299.tck.impl.packaging.Artifact;
 import org.testng.annotations.Test;
 
 /**
  * 
- * Spec version: PRD2
- *
+ * Spec version: Public Release Draft 2
+ * 
  */
+ at Artifact
 public class ResolutionByNameTest extends AbstractTest
 {
-   
+
    @Override
    protected List<Class<? extends Annotation>> getEnabledDeploymentTypes()
    {
@@ -29,121 +28,62 @@
    /**
     * The getInstanceByName() method must:
     * 
-    *  • Identify the Web Bean by calling Manager.resolveByName(), passing the name.
-    *  • If resolveByName() returned an empty set, return a null value.
-    *  • Otherwise, if exactly one Web Bean was returned, obtain an instance of the 
-    *    Web Bean by calling Manager.getInstance(), passing the Bean instance representing 
-    *    the Web Bean
+    * � Identify the Web Bean by calling Manager.resolveByName(), passing the
+    * name.
+    * 
+    * � If resolveByName() returned an empty set, return a null value.
+    * 
+    * � Otherwise, if exactly one Web Bean was returned, obtain an instance of
+    * the Web Bean by calling Manager.getInstance(), passing the Bean instance
+    * representing the Web Bean
+    * 
+    * @throws Exception
     */
-   @Test(groups={"stub", "el"}) 
-   @SpecAssertion(section="5.11", id = "unknown")
-   public void testELResolver()
-   {           
-      assert manager.getInstanceByName("nonexistant") == null;
-                
-      try
+   @Test(groups = { "resolution", "el" })
+   @SpecAssertion(section = "5.10", id = "unknown")
+   public void testELResolver() throws Exception
+   {
+      new RunInDependentContext()
       {
-         activateDependentContext();
-         Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);      
-         manager.addBean(salmonBean);      
-         assert manager.getInstanceByName("salmon") instanceof Salmon;
-      }
-      finally
-      {
-         deactivateDependentContext();
-      }
+
+         @Override
+         protected void execute() throws Exception
+         {
+            assert manager.getInstanceByName("nonexistant") == null;
+            assert manager.getInstanceByName("salmon") instanceof Salmon;
+         }
+
+      }.run();
    }
 
    /**
-    *  • Otherwise, if resolveByName() returned more than one Web Bean, throw an 
-    *    AmbiguousDependencyException.
+    * The following algorithm must be used by the container when resolving a
+    * bean by name:
+    * 
+    * • The container identifies the set of matching enabled beans which have
+    * the given name.
+    * 
+    * • Next, the container examines the deployment types of the matching beans,
+    * as defined in Section 2.5.7, “Deployment type precedence”, and returns the
+    * set of beans with the highest precedence deployment type that occurs in
+    * the set. If there are no matching beans, an empty set is returned.
+    * @throws Exception 
     */
-   @Test(expectedExceptions=AmbiguousDependencyException.class) 
-   @SpecAssertion(section="5.11", id = "unknown")
-   public void testDuplicateNamedBeans()
+   @Test(groups = { "resolution", "el" })
+   @SpecAssertion(section = "5.11", id = "unknown")
+   public void testOnlyHighestPrecedenceResolved() throws Exception
    {
-      try
+      // Both Cod and Plaice are named "whitefish" - Plaice has the highest
+      // deployment type (AnotherDeploymentType)
+      new RunInDependentContext()
       {
-         activateDependentContext();
+
+         @Override
+         protected void execute() throws Exception
+         {
+            assert manager.getInstanceByName("whitefish") instanceof Plaice;
+         }
          
-         Bean<Cod> codBean = createSimpleBean(Cod.class);
-         Bean<Sole> soleBean = createSimpleBean(Sole.class);
-         manager.addBean(codBean);
-         manager.addBean(soleBean);
-         
-         assert manager.resolveByName("whitefish").size() == 2;
-         manager.getInstanceByName("whitefish");
-      }
-      finally
-      {
-         deactivateDependentContext();
-      }
+      }.run();
    }
-   
-   @Test(groups="broken") @SpecAssertion(section="5.11", id = "unknown")
-   public void testNamedBasedResolution()
-   {
-      
-      Bean<Tuna> tunaBean = createSimpleBean(Tuna.class);
-      Bean<Cod> codBean = createSimpleBean(Cod.class);
-      Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);
-      Bean<Sole> soleBean = createSimpleBean(Sole.class);
-      Bean<SeaBass> seaBassBean = createSimpleBean(SeaBass.class);
-      Bean<Haddock> haddockBean = createSimpleBean(Haddock.class);
-      Bean<Plaice> plaiceBean = createSimpleBean(Plaice.class);
-      
-      manager.addBean(tunaBean);
-      manager.addBean(codBean);
-      manager.addBean(salmonBean);
-      manager.addBean(soleBean);
-      manager.addBean(haddockBean);
-      manager.addBean(seaBassBean);
-      
-      assert manager.resolveByName("salmon").size() == 1;
-      assert manager.resolveByName("salmon").contains(salmonBean);
-      
-      assert manager.resolveByName("whitefish").size() == 2;
-      assert manager.resolveByName("whitefish").contains(codBean);
-      assert manager.resolveByName("whitefish").contains(soleBean);
-      
-      manager.addBean(plaiceBean);
-      
-      assert manager.resolveByName("whitefish").size() == 1;
-      assert manager.resolveByName("whitefish").contains(plaiceBean);
-   }
-   
-   @Test(groups="resolution") @SpecAssertion(section="5.11", id = "unknown")
-   public void testNoWebBeansFound() throws Exception
-   {
-      Bean<Cod> codBean = createSimpleBean(Cod.class);
-      Bean<Salmon> salmonBean = createSimpleBean(Salmon.class);
-      
-      manager.addBean(codBean);
-      manager.addBean(salmonBean);
-      
-      assert manager.resolveByName("foo").size() == 0;
-   }
-   
-   /**
-    * The following algorithm must be used by the Web Bean manager when resolving a Web Bean by name:
-    * 
-    *  • The Web Bean manager identifies the set of matching enabled Web Beans which have the given name.
-    *  • Next, the Web Bean manager examines the deployment types of the matching Web Beans, as defined 
-    *    in Section 2.5.7, “Deployment type precedence”, and returns the set of Web Beans with the 
-    *    highest precedence deployment type that occurs in the set. If there are no matching Web Beans, 
-    *    an empty set is returned.
-    */
-   @Test(groups="stub") @SpecAssertion(section="5.11", id = "unknown")
-   public void testOnlyHighestPrecedenceResolved()
-   {
-      // Both Cod and Plaice are named "whitefish" - Plaice has the highest deployment type (AnotherDeploymentType)
-      Bean<Cod> codBean = createSimpleBean(Cod.class);
-      Bean<Plaice> plaiceBean = createSimpleBean(Plaice.class);
-      manager.addBean(codBean);
-      manager.addBean(plaiceBean); 
-      
-      assert manager.resolveByName("whitefish").size() == 1;
-      assert !manager.resolveByName("whitefish").contains(codBean);
-      assert manager.resolveByName("whitefish").contains(plaiceBean);
-   }   
 }




More information about the weld-commits mailing list