[webbeans-commits] Webbeans SVN: r21 - in ri/trunk/webbeans-impl/src: main/java/org/jboss/webbeans/bindings and 6 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Mon Jun 30 13:02:15 EDT 2008


Author: pete.muir at jboss.org
Date: 2008-06-30 13:02:15 -0400 (Mon, 30 Jun 2008)
New Revision: 21

Added:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java
Removed:
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
Modified:
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
   ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
   ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
Log:
Complete implementation of chapter 2 (less producer methods) with tests

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ComponentInstanceImpl.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -1,10 +1,8 @@
 package org.jboss.webbeans;
 
 import java.lang.annotation.Annotation;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.logging.Logger;
 
@@ -14,10 +12,10 @@
 import javax.webbeans.DeploymentType;
 import javax.webbeans.Named;
 import javax.webbeans.ScopeType;
-import javax.webbeans.Stereotype;
 
 import org.jboss.webbeans.bindings.CurrentBinding;
 import org.jboss.webbeans.bindings.DependentBinding;
+import org.jboss.webbeans.bindings.ProductionBinding;
 import org.jboss.webbeans.util.AnnotatedItem;
 import org.jboss.webbeans.util.LoggerUtil;
 
@@ -78,8 +76,24 @@
    
    protected static Class<?> getType(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
    {
-      // TODO Consider XML type
-      return annotatedItem.getAnnotatedClass();
+      if (annotatedItem.getAnnotatedClass() != null && xmlAnnotatedItem.getAnnotatedClass() != null && !annotatedItem.getAnnotatedClass().equals(xmlAnnotatedItem.getAnnotatedClass()))
+      {
+         throw new IllegalArgumentException("Cannot build a component which specifies different classes in XML and Java");
+      }
+      else if (xmlAnnotatedItem.getAnnotatedClass() != null)
+      {
+         log.finest("Component type specified in XML");
+         return xmlAnnotatedItem.getAnnotatedClass();
+      }
+      else if (annotatedItem.getAnnotatedClass() != null)
+      {
+         log.finest("Component type specified in Java");
+         return annotatedItem.getAnnotatedClass();
+      }
+      else
+      {
+         throw new IllegalArgumentException("Cannot build a component which doesn't specify a type");
+      }
    }
    
    /**
@@ -89,7 +103,8 @@
    {
       if (stereotypes.getSupportedScopes().size() > 0)
       {
-         if (!stereotypes.getSupportedScopes().contains(scopeType))
+         log.finest("Checking if " + scopeType + " is allowed");
+         if (!stereotypes.getSupportedScopes().contains(scopeType.annotationType()))
          {
             throw new RuntimeException("Scope " + scopeType + " is not an allowed by the component's stereotype");
          }
@@ -101,14 +116,12 @@
     */
    protected static void checkRequiredTypesImplemented(MergedComponentStereotypes stereotypes, Class<?> type)
    {
-      if (stereotypes.getRequiredTypes().size() > 0)
+      for (Class<?> requiredType : stereotypes.getRequiredTypes())
       {
-         // TODO This needs to check a lot more. Or we do through checking assignability
-         List<Class> classes = Arrays.asList(type.getInterfaces());
-         if (!classes.containsAll(stereotypes.getRequiredTypes()))
+         log.finest("Checking if required type " + requiredType + " is implemented");
+         if (!requiredType.isAssignableFrom(type))
          {
-            // TODO Ugh, improve this exception
-            throw new RuntimeException("Not all required types are implemented");
+            throw new RuntimeException("Required type " + requiredType + " isn't implement on " + type);
          }
       }
    }
@@ -126,8 +139,9 @@
       
       if (xmlScopes.size() == 1)
       {
-         log.info("Scope specified in XML");
-         return xmlScopes.iterator().next();
+         Annotation scope = xmlScopes.iterator().next();
+         log.finest("Scope " + scope + " specified in XML");
+         return scope;
       }
       
       Set<Annotation> scopes = annotatedItem.getAnnotations(ScopeType.class);
@@ -138,75 +152,95 @@
       
       if (scopes.size() == 1)
       {
-         log.info("Scope specified by annotation");
-         return scopes.iterator().next();
+         Annotation scope = scopes.iterator().next();
+         log.finest("Scope " + scope + " specified b annotation");
+         return scope;
       }
       
-      if (stereotypes.getPossibleScopeTypes().size() > 0)
+      if (stereotypes.getPossibleScopeTypes().size() == 1)
       {
-         return stereotypes.getPossibleScopeTypes().iterator().next();
+         Annotation scope = stereotypes.getPossibleScopeTypes().iterator().next();
+         log.finest("Scope " + scope + " specified by stereotype");
+         return scope;
       }
+      else if (stereotypes.getPossibleScopeTypes().size() > 1)
+      {
+         throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
+      }
       
+      log.finest("Using default @Dependent scope");
       return new DependentBinding();
    }
 
-   protected static Annotation initComponentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedElement, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
+   protected static Annotation initComponentType(MergedComponentStereotypes stereotypes, AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
    {
-      /*
-       *  TODO deployment types actually identify components to deploy - and so 
-       *  if declared in XML and java then there are two components to deploy - 
-       *  this needs to be handled at a higher level
-       *  
-       *  TODO Ignore deployment type annotations on class if declared in XML
-       */
-      Set<Annotation> xmlDeploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+      Set<Annotation> xmlDeploymentTypes = xmlAnnotatedItem.getAnnotations(DeploymentType.class);
       
       if (xmlDeploymentTypes.size() > 1)
       {
-         throw new RuntimeException("At most one deployment type may be specified in XML");
+         throw new RuntimeException("At most one deployment type may be specified (" + xmlDeploymentTypes + " are specified)");
       }
       
       if (xmlDeploymentTypes.size() == 1)
       {
-         return xmlDeploymentTypes.iterator().next();
+         Annotation deploymentType = xmlDeploymentTypes.iterator().next(); 
+         log.finest("Deployment type " + deploymentType + " specified in XML");
+         return deploymentType;
       }
       
-      Set<Annotation> deploymentTypes = annotatedElement.getAnnotations(DeploymentType.class);
+      if (xmlAnnotatedItem.getAnnotatedClass() == null)
+      {
       
-      if (deploymentTypes.size() > 1)
-      {
-         // TODO Improve the exception
-         throw new RuntimeException("At most one deployment type may be specified");
+         Set<Annotation> deploymentTypes = annotatedItem.getAnnotations(DeploymentType.class);
+         
+         if (deploymentTypes.size() > 1)
+         {
+            throw new RuntimeException("At most one deployment type may be specified (" + deploymentTypes + " are specified)");
+         }
+         if (deploymentTypes.size() == 1)
+         {
+            Annotation deploymentType = deploymentTypes.iterator().next();
+            log.finest("Deployment type " + deploymentType + " specified by annotation");
+            return deploymentType;
+         }
       }
-      if (deploymentTypes.size() == 1)
+      
+      if (stereotypes.getPossibleDeploymentTypes().size() > 0)
       {
-         return deploymentTypes.iterator().next();
+         Annotation deploymentType = getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
+         log.finest("Deployment type " + deploymentType + " specified by stereotype");
+         return deploymentType;
       }
       
-      if (stereotypes.getPossibleDeploymentTypes().size() > 0)
+      if (xmlAnnotatedItem.getAnnotatedClass() != null)
       {
-         return getDeploymentType(container.getEnabledDeploymentTypes(), stereotypes.getPossibleDeploymentTypes());
+         log.finest("Using default @Production deployment type");
+         return new ProductionBinding();
       }
-      
-      // TODO If declared in XML then we can return Production here
-      // TODO We shouldn't get here, but what to do if we have?
-      return null;
+      throw new RuntimeException("All Java annotated classes have a deployment type");
    }
 
-   protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedElement, AnnotatedItem xmlAnnotatedItem)
+   protected static Set<Annotation> initBindingTypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem)
    {
       Set<Annotation> xmlBindingTypes = xmlAnnotatedItem.getAnnotations(BindingType.class);
       if (xmlBindingTypes.size() > 0)
       {
          // TODO support producer expression default binding type
+         log.finest("Using binding types " + xmlBindingTypes + " specified in XML");
          return xmlBindingTypes;
       }
       
-      Set<Annotation> bindingTypes = annotatedElement.getAnnotations(BindingType.class);
+      Set<Annotation> bindingTypes = annotatedItem.getAnnotations(BindingType.class);
+      
       if (bindingTypes.size() == 0)
       {
+         log.finest("Adding default @Current binding type");
          bindingTypes.add(new CurrentBinding());
       }
+      else
+      {
+         log.finest("Using binding types " + bindingTypes + " specified by annotations");
+      }
       return bindingTypes;
    }
 
@@ -219,36 +253,45 @@
          name = xmlAnnotatedItem.getAnnotation(Named.class).value();
          if ("".equals(name))
          {
+            log.finest("Using default name (specified in XML)");
             componentNameDefaulted = true;
          }
+         else
+         {
+            log.finest("Using name " + name + " specified in XML");
+         }
       }
       else if (annotatedItem.isAnnotationPresent(Named.class))
       {
          name = annotatedItem.getAnnotation(Named.class).value();
          if ("".equals(name))
          {
+            log.finest("Using default name (specified by annotations)");
             componentNameDefaulted = true;
          }
+         else
+         {
+            log.finest("Using name " + name + " specified in XML");
+         }
       }
       if ("".equals(name) && (componentNameDefaulted || stereotypes.isComponentNameDefaulted()))
       {
          // TODO Write default name alogorithm
+         log.finest("Default name is TODO" );
       }
       return name;
    }
    
-   public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Set<Annotation> possibleDeploymentTypes)
+   public static Annotation getDeploymentType(List<Annotation> enabledDeploymentTypes, Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes)
    {
-      List<Annotation> l = new ArrayList<Annotation>(enabledDeploymentTypes);
-      l.retainAll(possibleDeploymentTypes);
-      if (l.size() > 0)
+      for (int i = (enabledDeploymentTypes.size() - 1); i > 0; i--)
       {
-         return l.get(0);
+         if (possibleDeploymentTypes.containsKey((enabledDeploymentTypes.get(i).annotationType())))
+         {
+            return enabledDeploymentTypes.get(i); 
+         }
       }
-      else
-      {
-         return null;
-      }
+      return null;
    }
 
    @Override

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/ContainerImpl.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -9,6 +9,7 @@
 import javax.webbeans.Container;
 import javax.webbeans.Context;
 import javax.webbeans.Observer;
+import javax.webbeans.Standard;
 import javax.webbeans.TypeLiteral;
 
 import org.jboss.webbeans.bindings.ProductionBinding;
@@ -20,21 +21,28 @@
    private List<Annotation> enabledDeploymentTypes;
    private StereotypeManager stereotypeManager;
    
-   public ContainerImpl()
+   public ContainerImpl(List<Annotation> enabledDeploymentTypes)
    {
-      initEnabledDeploymentTypes();
+      initEnabledDeploymentTypes(enabledDeploymentTypes);
       this.stereotypeManager = new StereotypeManager();
    }
    
-   private void initEnabledDeploymentTypes()
+   private void initEnabledDeploymentTypes(List<Annotation> enabledDeploymentTypes)
    {
       this.enabledDeploymentTypes = new ArrayList<Annotation>();
-      // TODO Support enabling custom deployment types
-      if (this.enabledDeploymentTypes.size() == 0)
+      if (enabledDeploymentTypes == null)
       {
          this.enabledDeploymentTypes.add(0, new StandardBinding());
          this.enabledDeploymentTypes.add(1, new ProductionBinding());
       }
+      else
+      {
+         this.enabledDeploymentTypes.addAll(enabledDeploymentTypes);
+         if (!this.enabledDeploymentTypes.get(0).annotationType().equals(Standard.class))
+         {
+            throw new RuntimeException("@Standard must be the lowest precedence deployment type");
+         }
+      }
    }
 
    public Container addComponent(ComponentInstance component)

Modified: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/MergedComponentStereotypes.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -1,7 +1,9 @@
 package org.jboss.webbeans;
 
 import java.lang.annotation.Annotation;
+import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
 
 import javax.webbeans.Stereotype;
@@ -16,7 +18,7 @@
 public class MergedComponentStereotypes
 {
 
-   private Set<Annotation> possibleDeploymentTypes;
+   private Map<Class<? extends Annotation>, Annotation> possibleDeploymentTypes;
    private Set<Annotation> possibleScopeTypes;
    private boolean componentNameDefaulted;
    private Set<Class<?>> requiredTypes;
@@ -24,7 +26,7 @@
    
    public MergedComponentStereotypes(AnnotatedItem annotatedItem, AnnotatedItem xmlAnnotatedItem, ContainerImpl container)
    {
-      possibleDeploymentTypes = new HashSet<Annotation>();
+      possibleDeploymentTypes = new HashMap<Class<? extends Annotation>, Annotation>();
       possibleScopeTypes = new HashSet<Annotation>();
       requiredTypes = new HashSet<Class<?>>();
       supportedScopes = new HashSet<Class<? extends Annotation>>();
@@ -38,9 +40,13 @@
       {
          // Retrieve and merge all metadata from stereotypes
          StereotypeMetaModel stereotype = container.getStereotypeManager().getStereotype(stereotypeAnnotation.annotationType());
+         if (stereotype == null)
+         {
+            throw new NullPointerException("Stereotype " + stereotypeAnnotation + " not registered with container");
+         }
          if (stereotype.getDefaultDeploymentType() != null)
          {
-            possibleDeploymentTypes.add(stereotype.getDefaultDeploymentType());
+            possibleDeploymentTypes.put(stereotype.getDefaultDeploymentType().annotationType(), stereotype.getDefaultDeploymentType());
          }
          if (stereotype.getDefaultScopeType() != null)
          {
@@ -53,14 +59,9 @@
             componentNameDefaulted = true;
          }
       }
-      
-      if (this.possibleScopeTypes.size() > 1)
-      {
-         throw new RuntimeException("All stereotypes must specify the same scope OR a scope must be specified on the component");
-      }
    }
    
-   public Set<Annotation> getPossibleDeploymentTypes()
+   public Map<Class<? extends Annotation>, Annotation> getPossibleDeploymentTypes()
    {
       return possibleDeploymentTypes;
    }

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.ConversationScoped;
+import javax.webbeans.DynamicBinding;
+
+public class ConversationScopedBinding extends DynamicBinding<ConversationScoped> implements ConversationScoped
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/ConversationScopedBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.bindings;
+
+import javax.webbeans.DynamicBinding;
+import javax.webbeans.RequestScoped;
+
+public class RequestScopedBinding extends DynamicBinding<RequestScoped> implements RequestScoped
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/main/java/org/jboss/webbeans/bindings/RequestScopedBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ClassAnnotatedItemTest.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -5,11 +5,10 @@
 import java.util.Set;
 
 import javax.webbeans.DeploymentType;
-import javax.webbeans.Named;
 import javax.webbeans.Production;
 import javax.webbeans.Stereotype;
 
-import org.jboss.webbeans.test.components.ClassWithNoAnnotations;
+import org.jboss.webbeans.test.components.Antelope;
 import org.jboss.webbeans.test.components.Order;
 import org.jboss.webbeans.util.AnnotatedItem;
 import org.jboss.webbeans.util.ClassAnnotatedItem;
@@ -22,10 +21,8 @@
    public void testDeclaredAnnotations()
    {
       AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
-      assert annotatedElement.getAnnotations().size() == 2;
+      assert annotatedElement.getAnnotations().size() == 1;
       assert annotatedElement.getAnnotation(Production.class) != null;
-      assert annotatedElement.getAnnotation(Named.class) != null;
-      System.out.println(annotatedElement.getAnnotatedClass());
       assert annotatedElement.getAnnotatedClass().equals(Order.class);
    }
    
@@ -46,7 +43,7 @@
       AnnotatedItem annotatedElement = new ClassAnnotatedItem(Order.class);
       assert annotatedElement.getAnnotation(Stereotype.class) == null;
       assert annotatedElement.getAnnotations(Stereotype.class).size() == 0;
-      AnnotatedItem classWithNoAnnotations = new ClassAnnotatedItem(ClassWithNoAnnotations.class);
+      AnnotatedItem classWithNoAnnotations = new ClassAnnotatedItem(Antelope.class);
       assert classWithNoAnnotations.getAnnotations().size() == 0;
    }
    

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ComponentInstanceTest.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -1,31 +1,66 @@
 package org.jboss.webbeans.test;
 
+import static org.jboss.webbeans.test.util.Util.annotationSetMatches;
+
 import java.lang.annotation.Annotation;
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import javax.webbeans.ApplicationScoped;
 import javax.webbeans.ComponentInstance;
+import javax.webbeans.ConversationScoped;
 import javax.webbeans.Current;
 import javax.webbeans.Dependent;
 import javax.webbeans.Named;
 import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
 
 import org.jboss.webbeans.ComponentInstanceImpl;
 import org.jboss.webbeans.ContainerImpl;
 import org.jboss.webbeans.StereotypeMetaModel;
+import org.jboss.webbeans.bindings.ConversationScopedBinding;
 import org.jboss.webbeans.bindings.CurrentBinding;
 import org.jboss.webbeans.bindings.NamedBinding;
+import org.jboss.webbeans.bindings.RequestScopedBinding;
+import org.jboss.webbeans.bindings.StandardBinding;
 import org.jboss.webbeans.test.annotations.AnimalStereotype;
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+import org.jboss.webbeans.test.annotations.Asynchronous;
+import org.jboss.webbeans.test.annotations.FishStereotype;
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+import org.jboss.webbeans.test.annotations.MammalStereotype;
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.test.annotations.RiverFishStereotype;
 import org.jboss.webbeans.test.annotations.Synchronous;
+import org.jboss.webbeans.test.bindings.AnimalStereotypeBinding;
+import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.AsynchronousBinding;
+import org.jboss.webbeans.test.bindings.FishStereotypeBinding;
+import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.HornedMamalStereotypeBinding;
+import org.jboss.webbeans.test.bindings.RiverFishStereotypeBinding;
 import org.jboss.webbeans.test.bindings.SynchronousBinding;
+import org.jboss.webbeans.test.components.Antelope;
+import org.jboss.webbeans.test.components.Carp;
+import org.jboss.webbeans.test.components.Cat;
+import org.jboss.webbeans.test.components.Chair;
+import org.jboss.webbeans.test.components.ComponentWithTooManyDeploymentTypes;
+import org.jboss.webbeans.test.components.ComponentWithTooManyScopeTypes;
+import org.jboss.webbeans.test.components.Goldfish;
 import org.jboss.webbeans.test.components.Gorilla;
+import org.jboss.webbeans.test.components.Haddock;
+import org.jboss.webbeans.test.components.Moose;
 import org.jboss.webbeans.test.components.Order;
+import org.jboss.webbeans.test.components.Trout;
+import org.jboss.webbeans.test.components.Tuna;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
 import org.jboss.webbeans.util.AnnotatedItem;
 import org.jboss.webbeans.util.ClassAnnotatedItem;
 import org.jboss.webbeans.util.MutableAnnotatedItem;
 import org.junit.Before;
-import org.junit.BeforeClass;
 import org.junit.Test;
 
 public class ComponentInstanceTest
@@ -33,75 +68,424 @@
    
    private ContainerImpl container;
    
-   private static AnnotatedItem emptyAnnotatedItem;
+   private AnnotatedItem emptyAnnotatedItem;
    
-   private static AnnotatedItem currentSynchronousOrder;
+   @Before
+   public void before()
+   {
+      emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+      
+      List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
+      enabledDeploymentTypes.add(new StandardBinding());
+      enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
+      enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
+      container = new MockContainerImpl(enabledDeploymentTypes);
+      
+      initStereotypes(container);
+   }
    
-   @BeforeClass
-   public static void beforeClass()
+   private void initStereotypes(ContainerImpl container)
    {
-      Map<Class<? extends Annotation>, Annotation> orderXmlAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
-      orderXmlAnnotations.put(Current.class, new CurrentBinding());
-      orderXmlAnnotations.put(Synchronous.class, new SynchronousBinding());
-      orderXmlAnnotations.put(Named.class, new NamedBinding()
+      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(HornedMammalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(MammalStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(FishStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RiverFishStereotype.class)));
+      container.getStereotypeManager().addStereotype(new StereotypeMetaModel(new ClassAnnotatedItem(RequestScopedAnimalStereotype.class)));
+   }
+   
+   @Test
+   public void testTooManyDeploymentTypes()
+   {
+      boolean exception = false;
+      try
       {
-         public String value()
-         {
-            return "currentSynchronousOrder";
-         }
-      });
-      currentSynchronousOrder = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
+         new ComponentInstanceImpl<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   // **** TESTS FOR DEPLOYMENT TYPE **** //
+   
+   @Test
+   public void testXmlDeploymentTypeOverridesJava()
+   {
+      Map<Class<? extends Annotation>, Annotation> xmlDefinedDeploymentTypeAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      xmlDefinedDeploymentTypeAnnotations.put(AnotherDeploymentType.class, new AnotherDeploymentTypeBinding());
+      AnnotatedItem xmlDefinedDeploymentTypeAnnotatedItem = new MutableAnnotatedItem(ComponentWithTooManyDeploymentTypes.class, xmlDefinedDeploymentTypeAnnotations);
       
-      emptyAnnotatedItem = new MutableAnnotatedItem(null, new HashMap<Class<? extends Annotation>, Annotation>());
+      ComponentInstance<ComponentWithTooManyDeploymentTypes> component = new ComponentInstanceImpl<ComponentWithTooManyDeploymentTypes>(new ClassAnnotatedItem(ComponentWithTooManyDeploymentTypes.class), xmlDefinedDeploymentTypeAnnotatedItem, container);
+      assert component.getComponentType().annotationType().equals(AnotherDeploymentType.class);
    }
    
-   @Before
-   public void before()
+   @Test
+   public void testXmlDefaultDeploymentType()
    {
-      // TODO Probably need a mock container
-      container = new ContainerImpl();
-      StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
-      container.getStereotypeManager().addStereotype(animalStereotype);
+      AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, new HashMap<Class<? extends Annotation>, Annotation>());
+      ComponentInstance<Antelope> antelope = new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+      assert antelope.getComponentType().annotationType().equals(Production.class);
    }
-
+   
+   @Test
+   public void testXmlIgnoresJavaDeploymentType()
+   {
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Tuna.class, new HashMap<Class<? extends Annotation>, Annotation>());
+      ComponentInstance<Tuna> tuna = new ComponentInstanceImpl<Tuna>(new ClassAnnotatedItem(Tuna.class), annotatedItem, container);
+      assert tuna.getComponentType().annotationType().equals(Production.class);
+   }
+   
+   @Test
+   public void testDeploymentTypePrecedenceSelection()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(HornedMammalStereotype.class, new HornedMamalStereotypeBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Moose.class, annotations);
+      
+      ComponentInstance<Moose> moose = new ComponentInstanceImpl<Moose>(new ClassAnnotatedItem(Moose.class), annotatedItem, container);
+      assert moose.getComponentType().annotationType().equals(HornedAnimalDeploymentType.class);
+      
+   }
+   
+   // **** TESTS FOR BINDING TYPE **** //
+   
    @SuppressWarnings("unchecked")
    @Test
-   public void testOrder()
+   public void testXmlBindingTypeOverridesJava()
    {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(Asynchronous.class, new AsynchronousBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Cat.class, annotations);
       
+      ComponentInstance<Cat> cat = new ComponentInstanceImpl<Cat>(new ClassAnnotatedItem(Cat.class), annotatedItem, container);
+      assert cat.getBindingTypes().size() == 1;
+      assert annotationSetMatches(cat.getBindingTypes(), Asynchronous.class);
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testBindingTypesDeclaredInJava()
+   {
+      ComponentInstance<Cat> cat = new ComponentInstanceImpl<Cat>(new ClassAnnotatedItem(Cat.class), emptyAnnotatedItem, container);
+      assert cat.getBindingTypes().size() == 1;
+      assert annotationSetMatches(cat.getBindingTypes(), Synchronous.class);
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testBindingTypesDeclaredInXml()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(Asynchronous.class, new AsynchronousBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
+      
+      ComponentInstance<Antelope> antelope = new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, annotatedItem, container);
+      assert annotationSetMatches(antelope.getBindingTypes(), Asynchronous.class);
+   }
+   
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testDefaultBindingType()
+   {
       ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
-      assert Production.class.equals(order.getComponentType().annotationType());
-      assert "order".equals(order.getName());
       assert order.getBindingTypes().size() == 1;
       order.getBindingTypes().iterator().next().annotationType().equals(Current.class);
+   }
+   
+   // **** TESTS FOR SCOPES **** //
+   
+   @Test
+   public void testScopeDeclaredInJava()
+   {
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), emptyAnnotatedItem, container);
+      assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+   }
+   
+   @Test
+   public void testScopeDeclaredInXml()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(RequestScoped.class, new RequestScopedBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Order.class, annotations);
+      
+      ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), annotatedItem, container);
+      assert order.getScopeType().annotationType().equals(RequestScoped.class);
+   }
+   
+   @Test
+   public void testScopeDeclaredInXmlOverridesJava()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(ConversationScoped.class, new ConversationScopedBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+      assert trout.getScopeType().annotationType().equals(ConversationScoped.class);
+   }
+   
+   @Test
+   public void testScopeMissingInXml()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+      
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+      assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+   }
+   
+   @Test
+   public void testNoScopeSpecified()
+   {
+      ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), emptyAnnotatedItem, container);
       assert order.getScopeType().annotationType().equals(Dependent.class);
-      //assert order.getTypes() == ??
    }
    
+   @Test
+   public void testTooManyScopesSpecified()
+   {
+      boolean exception = false;
+      try
+      {
+         new ComponentInstanceImpl<ComponentWithTooManyScopeTypes>(new ClassAnnotatedItem(ComponentWithTooManyScopeTypes.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;  
+   }
+   
+   @Test
+   public void testTooManyScopesSpecifiedInXml()
+   {
+      boolean exception = false;
+      try
+      {
+         Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+         annotations.put(RequestScoped.class, new RequestScopedBinding());
+         annotations.put(ConversationScoped.class, new ConversationScopedBinding());
+         AnnotatedItem antelopeAnnotatedItem = new MutableAnnotatedItem(Antelope.class, annotations);
+         new ComponentInstanceImpl<Antelope>(emptyAnnotatedItem, antelopeAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;  
+   }
+   
+   @Test
+   public void testScopeSpecifiedAndStereotyped()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(FishStereotype.class, new FishStereotypeBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+      assert trout.getScopeType().annotationType().equals(RequestScoped.class);
+   }
+   
+   @Test
+   public void testMutipleIncompatibleScopeStereotypes()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(FishStereotype.class, new FishStereotypeBinding());
+      annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
+      
+      boolean exception = false;
+      try
+      {
+         new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @Test
+   public void testMutipleIncompatibleScopeStereotypesWithScopeSpecified()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(FishStereotype.class, new FishStereotypeBinding());
+      annotations.put(AnimalStereotype.class, new AnimalStereotypeBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+      
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+      assert trout.getScopeType().annotationType().equals(RequestScoped.class);     
+   }
+   
+   @Test
+   public void testMutipleCompatibleScopeStereotypes()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(FishStereotype.class, new FishStereotypeBinding());
+      annotations.put(RiverFishStereotype.class, new RiverFishStereotypeBinding());
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Haddock.class, annotations);
+      
+      ComponentInstance<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), annotatedItem, container);
+      assert haddock.getScopeType().annotationType().equals(ApplicationScoped.class);
+   }
+   
+   // **** TESTS FOR COMPONENT NAME **** /
+   
+   @Test
+   public void testNamed()
+   {
+      ComponentInstance<Haddock> haddock = new ComponentInstanceImpl<Haddock>(new ClassAnnotatedItem(Haddock.class), emptyAnnotatedItem, container);
+      assert haddock.getName() != null;
+      // TODO Test naming algorithms
+   }
+   
+   @Test
+   public void testXmlNamed()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(Named.class, new NamedBinding()
+      {
+
+         public String value()
+         {
+            return "";
+         }
+      });
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+      
+      assert trout.getName() != null;
+      // TODO Test naming algorithms
+   }
+   
+   @Test
+   public void testNonDefaultXmlNamed()
+   {
+      Map<Class<? extends Annotation>, Annotation> annotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      annotations.put(Named.class, new NamedBinding()
+      {
+
+         public String value()
+         {
+            return "aTrout";
+         }
+      });
+      AnnotatedItem annotatedItem = new MutableAnnotatedItem(Trout.class, annotations);
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), annotatedItem, container);
+      
+      assert trout.getName().equals("aTrout");
+   }
+   
+   @Test
+   public void testNotNamed()
+   {
+      ComponentInstance<Trout> trout = new ComponentInstanceImpl<Trout>(new ClassAnnotatedItem(Trout.class), emptyAnnotatedItem, container);
+      assert trout.getName() == null;
+   }
+   
+   @Test
+   public void testNonDefaultNamed()
+   {
+      ComponentInstance<Moose> moose = new ComponentInstanceImpl<Moose>(new ClassAnnotatedItem(Moose.class), emptyAnnotatedItem, container);
+      assert moose.getName().equals("aMoose");
+   }
+   
+   
+   // **** TESTS FOR STEREOTYPES **** //
+   
    @SuppressWarnings("unchecked")
    @Test
-   public void testCurrentSynchronousOrder()
+   public void testStereotypeDeclaredInXmlAndJava()
    {
-      ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrder, container);
+      Map<Class<? extends Annotation>, Annotation> orderXmlAnnotations = new HashMap<Class<? extends Annotation>, Annotation>();
+      orderXmlAnnotations.put(Current.class, new CurrentBinding());
+      orderXmlAnnotations.put(Synchronous.class, new SynchronousBinding());
+      orderXmlAnnotations.put(Named.class, new NamedBinding()
+      {
+         public String value()
+         {
+            return "currentSynchronousOrder";
+         }
+      });
+      AnnotatedItem currentSynchronousOrderAnnotatedItem = new MutableAnnotatedItem(Order.class, orderXmlAnnotations);
+      
+      ComponentInstance<Order> order = new ComponentInstanceImpl<Order>(new ClassAnnotatedItem(Order.class), currentSynchronousOrderAnnotatedItem, container);
       assert Production.class.equals(order.getComponentType().annotationType());
       assert "currentSynchronousOrder".equals(order.getName());
       assert order.getBindingTypes().size() == 2;
-      for (Annotation annotation : order.getBindingTypes())
-      {
-         // TODO Write a utility class to do this type of test
-         assert annotation.annotationType().equals(Current.class) || annotation.annotationType().equals(Synchronous.class);
-      }
+      assert annotationSetMatches(order.getBindingTypes(), Current.class, Synchronous.class);
       assert order.getScopeType().annotationType().equals(Dependent.class);
    }
    
    @Test
-   public void testGorilla()
+   public void testSingleStereotype()
    {
       ComponentInstance<Gorilla> gorilla = new ComponentInstanceImpl<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
       assert gorilla.getName() == null;
-      // TODO Ensure that the a java declared component declares a deployment type
-      //assert gorilla.getComponentType() == null;
+      assert gorilla.getComponentType().annotationType().equals(Production.class);
       assert gorilla.getBindingTypes().iterator().next().annotationType().equals(Current.class);
-      assert gorilla.getScopeType().annotationType().equals(Dependent.class);
+      assert gorilla.getScopeType().annotationType().equals(RequestScoped.class);
    }
+   
+   @Test
+   public void testRequiredTypeIsImplemented()
+   {
+      try
+      {
+         new ComponentInstanceImpl<Gorilla>(new ClassAnnotatedItem(Gorilla.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         assert false;
+      }
+      
+   }
+   
+   @Test
+   public void testRequiredTypeIsNotImplemented()
+   {
+      boolean exception = false;
+      try
+      {
+         new ComponentInstanceImpl<Chair>(new ClassAnnotatedItem(Chair.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+      
+   }
+   
+   @Test
+   public void testScopeIsSupported()
+   {
+      try
+      {
+         new ComponentInstanceImpl<Goldfish>(new ClassAnnotatedItem(Goldfish.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         e.printStackTrace();
+         assert false;
+      }
+      
+   }
+   
+   @Test
+   public void testScopeIsNotSupported()
+   {
+      boolean exception = false;
+      try
+      {
+         new ComponentInstanceImpl<Carp>(new ClassAnnotatedItem(Carp.class), emptyAnnotatedItem, container);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+      
+   }
 }

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,63 @@
+package org.jboss.webbeans.test;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.webbeans.Production;
+import javax.webbeans.Standard;
+
+import org.jboss.webbeans.ContainerImpl;
+import org.jboss.webbeans.bindings.StandardBinding;
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+import org.jboss.webbeans.test.bindings.AnotherDeploymentTypeBinding;
+import org.jboss.webbeans.test.bindings.HornedAnimalDeploymentTypeBinding;
+import org.jboss.webbeans.test.mock.MockContainerImpl;
+import org.junit.Test;
+
+public class ContainerTest
+{
+   
+   @Test
+   public void testDefaultEnabledDeploymentTypes()
+   {
+      ContainerImpl container = new MockContainerImpl(null);
+      assert container.getEnabledDeploymentTypes().size() == 2;
+      assert container.getEnabledDeploymentTypes().get(0).annotationType().equals(Standard.class);
+      assert container.getEnabledDeploymentTypes().get(1).annotationType().equals(Production.class);
+   }
+
+   @Test
+   public void testCustomDeploymentTypes()
+   {
+      List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
+      enabledDeploymentTypes.add(new StandardBinding());
+      enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
+      enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
+      ContainerImpl container = new MockContainerImpl(enabledDeploymentTypes);
+      assert container.getEnabledDeploymentTypes().size() == 3;
+      assert container.getEnabledDeploymentTypes().get(0).annotationType().equals(Standard.class);
+      assert container.getEnabledDeploymentTypes().get(1).annotationType().equals(AnotherDeploymentType.class);
+      assert container.getEnabledDeploymentTypes().get(2).annotationType().equals(HornedAnimalDeploymentType.class);
+   }
+   
+   @Test
+   public void testStandardMustBeDeclared()
+   {
+      List<Annotation> enabledDeploymentTypes = new ArrayList<Annotation>();
+      enabledDeploymentTypes.add(new AnotherDeploymentTypeBinding());
+      enabledDeploymentTypes.add(new HornedAnimalDeploymentTypeBinding());
+      boolean exception = false;
+      try
+      {
+         new MockContainerImpl(enabledDeploymentTypes);
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/ContainerTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/StereotypeMetaModelTest.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -11,6 +11,10 @@
 import org.jboss.webbeans.test.annotations.AnimalOrderStereotype;
 import org.jboss.webbeans.test.annotations.AnimalStereotype;
 import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+import org.jboss.webbeans.test.annotations.StereotypeWithBindingTypes;
+import org.jboss.webbeans.test.annotations.StereotypeWithNonEmptyNamed;
+import org.jboss.webbeans.test.annotations.StereotypeWithTooManyDeploymentTypes;
+import org.jboss.webbeans.test.annotations.StereotypeWithTooManyScopeTypes;
 import org.jboss.webbeans.test.components.Animal;
 import org.jboss.webbeans.test.components.Order;
 import org.jboss.webbeans.util.ClassAnnotatedItem;
@@ -48,10 +52,10 @@
    public void testAnimalStereotype()
    {
       StereotypeMetaModel animalStereotype = new StereotypeMetaModel(new ClassAnnotatedItem(AnimalStereotype.class));
-      assert animalStereotype.getDefaultScopeType() == null;
+      assert animalStereotype.getDefaultScopeType().annotationType().equals(RequestScoped.class);
       assert animalStereotype.getInterceptorBindings().size() == 0;
       assert animalStereotype.getRequiredTypes().size() == 1;
-      assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
+      assert animalStereotype.getRequiredTypes().contains(Animal.class);
       assert animalStereotype.getSupportedScopes().size() == 0;
       assert !animalStereotype.isComponentNameDefaulted();
       assert animalStereotype.getDefaultDeploymentType() == null;
@@ -80,9 +84,69 @@
       assert animalStereotype.getRequiredTypes().size() == 1;
       assert Animal.class.equals(animalStereotype.getRequiredTypes().iterator().next());
       assert animalStereotype.getSupportedScopes().size() == 1;
-      assert RequestScoped.class.equals(animalStereotype.getSupportedScopes().iterator().next());
+      assert animalStereotype.getSupportedScopes().contains(RequestScoped.class);
       assert !animalStereotype.isComponentNameDefaulted();
       assert animalStereotype.getDefaultDeploymentType() == null;
    }
    
+   @Test
+   public void testStereotypeWithTooManyScopeTypes()
+   {
+      boolean exception = false;
+      try
+      {
+         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyScopeTypes.class));
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @Test
+   public void testStereotypeWithTooManyDeploymentTypes()
+   {
+      boolean exception = false;
+      try
+      {
+         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithTooManyDeploymentTypes.class));
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @Test
+   public void testStereotypeWithNonEmptyNamed()
+   {
+      boolean exception = false;
+      try
+      {
+         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithNonEmptyNamed.class));
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
+   @Test
+   public void testStereotypeWithBindingTypes()
+   {
+      boolean exception = false;
+      try
+      {
+         new StereotypeMetaModel(new ClassAnnotatedItem(StereotypeWithBindingTypes.class));
+      }
+      catch (Exception e) 
+      {
+         exception = true;
+      }
+      assert exception;
+   }
+   
 }

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnimalStereotype.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -6,6 +6,7 @@
 import java.lang.annotation.Retention;
 import java.lang.annotation.Target;
 
+import javax.webbeans.RequestScoped;
 import javax.webbeans.Stereotype;
 
 import org.jboss.webbeans.test.components.Animal;
@@ -13,6 +14,7 @@
 @Stereotype(requiredTypes=Animal.class)
 @Target( { TYPE })
 @Retention(RUNTIME)
+ at RequestScoped
 public @interface AnimalStereotype
 {
 

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.DeploymentType;
+
+ at Target( { TYPE, METHOD })
+ at Retention(RUNTIME)
+ at Documented
+ at DeploymentType
+public @interface AnotherDeploymentType
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/AnotherDeploymentType.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.BindingType;
+
+ at Target( { TYPE, METHOD })
+ at Retention(RUNTIME)
+ at Documented
+ at BindingType
+public @interface Asynchronous
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/Asynchronous.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+ at Stereotype(requiredTypes=Animal.class)
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at ApplicationScoped
+public @interface FishStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/FishStereotype.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.DeploymentType;
+
+ at Target( { TYPE, METHOD })
+ at Retention(RUNTIME)
+ at Documented
+ at DeploymentType
+public @interface HornedAnimalDeploymentType
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedAnimalDeploymentType.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+ at Stereotype(requiredTypes=Animal.class)
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at HornedAnimalDeploymentType
+public @interface HornedMammalStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/HornedMammalStereotype.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+ at Stereotype(requiredTypes=Animal.class)
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at AnotherDeploymentType
+public @interface MammalStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/MammalStereotype.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.Stereotype;
+
+import org.jboss.webbeans.test.components.Animal;
+
+ at Stereotype(requiredTypes=Animal.class)
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at ApplicationScoped
+public @interface RiverFishStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/RiverFishStereotype.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,21 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.ApplicationScoped;
+import javax.webbeans.RequestScoped;
+import javax.webbeans.Stereotype;
+
+ at Stereotype
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at ApplicationScoped
+ at RequestScoped
+public @interface StereotypeWithBindingTypes
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithBindingTypes.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,19 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Named;
+import javax.webbeans.Stereotype;
+
+ at Stereotype
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at Named("foo")
+public @interface StereotypeWithNonEmptyNamed
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithNonEmptyNamed.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,20 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.webbeans.Production;
+import javax.webbeans.Stereotype;
+
+ at Stereotype
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at Production
+ at AnotherDeploymentType
+public @interface StereotypeWithTooManyDeploymentTypes
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyDeploymentTypes.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,17 @@
+package org.jboss.webbeans.test.annotations;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import javax.webbeans.Stereotype;
+
+ at Stereotype
+ at Target( { TYPE })
+ at Retention(RUNTIME)
+ at Asynchronous
+public @interface StereotypeWithTooManyScopeTypes
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/annotations/StereotypeWithTooManyScopeTypes.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+
+public class AnimalStereotypeBinding extends DynamicBinding<AnimalStereotype> implements AnimalStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnimalStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+
+public class AnotherDeploymentTypeBinding extends DynamicBinding<AnotherDeploymentType> implements AnotherDeploymentType {}
\ No newline at end of file


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AnotherDeploymentTypeBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+/**
+ * 
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.Asynchronous;
+
+
+public class AsynchronousBinding extends DynamicBinding<Asynchronous> implements Asynchronous {}
\ No newline at end of file


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/AsynchronousBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.RiverFishStereotype;
+
+public class FishStereotypeBinding extends DynamicBinding<RiverFishStereotype> implements RiverFishStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/FishStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.HornedAnimalDeploymentType;
+
+public class HornedAnimalDeploymentTypeBinding extends DynamicBinding<HornedAnimalDeploymentType> implements HornedAnimalDeploymentType {}
\ No newline at end of file


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedAnimalDeploymentTypeBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+/**
+ * 
+ */
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.HornedMammalStereotype;
+
+public class HornedMamalStereotypeBinding extends DynamicBinding<HornedMammalStereotype> implements HornedMammalStereotype {}
\ No newline at end of file


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/HornedMamalStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,10 @@
+package org.jboss.webbeans.test.bindings;
+
+import javax.webbeans.DynamicBinding;
+
+import org.jboss.webbeans.test.annotations.FishStereotype;
+
+public class RiverFishStereotypeBinding extends DynamicBinding<FishStereotype> implements FishStereotype
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/bindings/RiverFishStereotypeBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,6 @@
+package org.jboss.webbeans.test.components;
+
+public class Antelope implements Animal
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Antelope.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+
+ at RequestScopedAnimalStereotype
+public class Carp implements Animal
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Carp.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.Synchronous;
+
+ at Production
+ at Synchronous
+public class Cat
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Cat.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import org.jboss.webbeans.test.annotations.AnimalStereotype;
+
+ at AnimalStereotype
+public class Chair
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Chair.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Deleted: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ClassWithNoAnnotations.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -1,6 +0,0 @@
-package org.jboss.webbeans.test.components;
-
-public class ClassWithNoAnnotations
-{
-
-}

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+
+ at Production
+ at AnotherDeploymentType
+public class ComponentWithTooManyDeploymentTypes
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyDeploymentTypes.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.ConversationScoped;
+import javax.webbeans.RequestScoped;
+
+ at RequestScoped
+ at ConversationScoped
+public class ComponentWithTooManyScopeTypes
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/ComponentWithTooManyScopeTypes.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,14 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+import org.jboss.webbeans.test.annotations.RequestScopedAnimalStereotype;
+
+ at RequestScopedAnimalStereotype
+ at RequestScoped
+ at Production
+public class Goldfish implements Animal
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Goldfish.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Gorilla.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -1,8 +1,11 @@
 package org.jboss.webbeans.test.components;
 
+import javax.webbeans.Production;
+
 import org.jboss.webbeans.test.annotations.AnimalStereotype;
 
 @AnimalStereotype
+ at Production
 public class Gorilla implements Animal
 {
 

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Named;
+import javax.webbeans.Production;
+
+ at Production
+ at Named
+public class Haddock implements Animal
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Haddock.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,12 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Named;
+
+import org.jboss.webbeans.test.annotations.MammalStereotype;
+
+ at MammalStereotype
+ at Named("aMoose")
+public class Moose implements Animal
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Moose.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java	2008-06-30 14:50:25 UTC (rev 20)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Order.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -1,10 +1,8 @@
 package org.jboss.webbeans.test.components;
 
-import javax.webbeans.Named;
 import javax.webbeans.Production;
 
 @Production
- at Named("order")
 public class Order
 {
 

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,11 @@
+package org.jboss.webbeans.test.components;
+
+import javax.webbeans.Production;
+import javax.webbeans.RequestScoped;
+
+ at Production
+ at RequestScoped
+public class Trout implements Animal
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Trout.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,9 @@
+package org.jboss.webbeans.test.components;
+
+import org.jboss.webbeans.test.annotations.AnotherDeploymentType;
+
+ at AnotherDeploymentType
+public class Tuna
+{
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/components/Tuna.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,16 @@
+package org.jboss.webbeans.test.mock;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+import org.jboss.webbeans.ContainerImpl;
+
+public class MockContainerImpl extends ContainerImpl
+{
+   
+   public MockContainerImpl(List<Annotation> enabledDeploymentTypes)
+   {
+      super(enabledDeploymentTypes);
+   }
+
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/mock/MockContainerImpl.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java
===================================================================
--- ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java	                        (rev 0)
+++ ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java	2008-06-30 17:02:15 UTC (rev 21)
@@ -0,0 +1,48 @@
+package org.jboss.webbeans.test.util;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+public class Util
+{
+
+   public static boolean annotationSetMatches(Set<Annotation> annotations, Class<? extends Annotation>... annotationTypes)
+   {
+      List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
+      annotationTypeList.addAll(Arrays.asList(annotationTypes));
+      for (Annotation annotation : annotations)
+      {
+         if (annotationTypeList.contains(annotation.annotationType()))
+         {
+            annotationTypeList.remove(annotation.annotationType());
+         }
+         else
+         {
+            return false;
+         }
+      }
+      return annotationTypeList.size() == 0;
+   }
+   
+   public static boolean annotationTypeSetMatches(Set<Class<? extends Annotation>> annotations, Class<? extends Annotation>... annotationTypes)
+   {
+      List<Class<? extends Annotation>> annotationTypeList = new ArrayList<Class<? extends Annotation>>();
+      annotationTypeList.addAll(Arrays.asList(annotationTypes));
+      for (Class<? extends Annotation> annotation : annotations)
+      {
+         if (annotationTypeList.contains(annotation))
+         {
+            annotationTypeList.remove(annotation);
+         }
+         else
+         {
+            return false;
+         }
+      }
+      return annotationTypeList.size() == 0;
+   }
+   
+}


Property changes on: ri/trunk/webbeans-impl/src/test/java/org/jboss/webbeans/test/util/Util.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain




More information about the weld-commits mailing list