[webbeans-commits] Webbeans SVN: r3385 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard and 2 other directories.

webbeans-commits at lists.jboss.org webbeans-commits at lists.jboss.org
Fri Jul 31 10:09:53 EDT 2009


Author: pete.muir at jboss.org
Date: 2009-07-31 10:09:49 -0400 (Fri, 31 Jul 2009)
New Revision: 3385

Added:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacade.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceImpl.java
Removed:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
Modified:
   ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
   ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
   tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/RemotePaymentProcessor.java
Log:
WBRI-307

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/BeanManagerImpl.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -682,7 +682,7 @@
          {
             throw new IllegalArgumentException("Cannot resolve a type parameterized with a wildcard " + element);
          }
-         if (type instanceof TypeVariable)
+         if (type instanceof TypeVariable<?>)
          {
             throw new IllegalArgumentException("Cannot resolve a type parameterized with a type parameter " + element);
          }

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -1,109 +0,0 @@
-/*
- * 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.webbeans;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
-
-/**
- * Common implementation for binding-type-based helpers
- * 
- * @author Gavin King
- * 
- * @param <T>
- */
-public abstract class FacadeImpl<T> implements Serializable
-{
-   
-   private static final long serialVersionUID = 8710258788495459128L;
-
-   private static final Annotation[] EMPTY_BINDINGS = new Annotation[0];
-   
-   // The binding types the helper operates on
-   private final Set<? extends Annotation> bindings;
-   // The Web Beans manager
-   private final BeanManagerImpl manager;
-   // The type of the operation
-   private final Type type;
-
-   /**
-    * 
-    * @param type The event type
-    * @param manager The Web Beans manager
-    * @param bindings The binding types
-    */
-   protected FacadeImpl(Type type, BeanManagerImpl manager, Set<? extends Annotation> bindings)
-   {
-      this.manager = manager;
-      this.type = type;
-      // Need to make sure the Set is serializable, some sets from Google Collections aren't
-      // TODO Work out how to not do this
-      this.bindings = new HashSet<Annotation>(bindings);
-   }
-
-   /**
-    * Gets a string representation
-    * 
-    * @return A string representation
-    */
-   @Override
-   public String toString()
-   {
-      return "Abstract facade implmentation";
-   }
-   
-   protected Annotation[] mergeInBindings(Annotation... newBindings)
-   {
-      Set<Annotation> result = new HashSet<Annotation>();
-      result.addAll(bindings);
-      for (Annotation newAnnotation : newBindings)
-      {
-         if (!getManager().getServices().get(MetaAnnotationStore.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
-         {
-            throw new IllegalArgumentException(newAnnotation + " is not a binding for " + this);
-         }
-         if (result.contains(newAnnotation))
-         {
-            throw new IllegalArgumentException(newAnnotation + " is already present in the bindings list for " + this);
-         }
-         result.add(newAnnotation);
-      }
-      return result.toArray(EMPTY_BINDINGS);
-   }
-
-   protected BeanManagerImpl getManager()
-   {
-      return manager.getCurrent();
-   }
-   
-   protected Set<? extends Annotation> getBindings()
-   {
-      return Collections.unmodifiableSet(bindings);
-   }
-   
-   protected Type getType()
-   {
-      return type;
-   }
-
-}
\ No newline at end of file

Deleted: ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -1,119 +0,0 @@
-/*
- * 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.webbeans;
-
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.enterprise.inject.Instance;
-import javax.enterprise.inject.TypeLiteral;
-import javax.enterprise.inject.spi.Bean;
-
-import org.jboss.webbeans.resolution.ResolvableWBClass;
-
-/**
- * Helper implementation for Instance for getting instances
- * 
- * @author Gavin King
- * 
- * @param <T>
- */
-public class InstanceImpl<T> extends FacadeImpl<T> implements Instance<T>, Serializable
-{
-
-   private static final long serialVersionUID = -376721889693284887L;
-
-   public static <I> Instance<I> of(Type type, BeanManagerImpl manager, Set<Annotation> annotations)
-   {
-      return new InstanceImpl<I>(type, manager, annotations);
-   }
-   
-   private InstanceImpl(Type type, BeanManagerImpl manager, Set<Annotation> bindings)
-   {
-      super(type, manager, bindings);
-   }
-
-   public T get(Annotation... bindings) 
-   {
-      Annotation[] annotations = mergeInBindings(bindings);
-      Bean<T> bean = getManager().getBean(ResolvableWBClass.<T>of(getType(), annotations, getManager()), annotations);
-      
-      @SuppressWarnings("unchecked")
-      T instance = (T) getManager().getReference(bean, getType(), getManager().createCreationalContext(bean));
-      return instance;
-   }
-
-   /**
-    * Gets a string representation
-    * 
-    * @return A string representation
-    */
-   @Override
-   public String toString()
-   {
-      return "Obtainable instance for type " + getType() + " and binding types " + getBindings();
-   }
-
-   public Iterator<T> iterator()
-   {
-      throw new UnsupportedOperationException("Not yet implemented");
-   }
-
-   /* (non-Javadoc)
-    * @see javax.enterprise.inject.Instance#isAmbiguous()
-    */
-   public boolean isAmbiguous()
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   /* (non-Javadoc)
-    * @see javax.enterprise.inject.Instance#isUnsatisfied()
-    */
-   public boolean isUnsatisfied()
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   /* (non-Javadoc)
-    * @see javax.enterprise.inject.Instance#select(java.lang.annotation.Annotation[])
-    */
-   public Instance<T> select(Annotation... bindings)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   /* (non-Javadoc)
-    * @see javax.enterprise.inject.Instance#select(java.lang.Class, java.lang.annotation.Annotation[])
-    */
-   public <U extends T> Instance<U> select(Class<U> subtype, Annotation... bindings)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-   /* (non-Javadoc)
-    * @see javax.enterprise.inject.Instance#select(javax.enterprise.inject.TypeLiteral, java.lang.annotation.Annotation[])
-    */
-   public <U extends T> Instance<U> select(TypeLiteral<U> subtype, Annotation... bindings)
-   {
-      throw new UnsupportedOperationException();
-   }
-
-}

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacade.java (from rev 3380, ri/trunk/impl/src/main/java/org/jboss/webbeans/FacadeImpl.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacade.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/AbstractFacade.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -0,0 +1,110 @@
+/*
+ * 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.webbeans.bean.standard;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.metadata.cache.MetaAnnotationStore;
+
+/**
+ * Common implementation for binding-type-based helpers
+ * 
+ * @author Gavin King
+ * 
+ * @param <T>
+ */
+public abstract class AbstractFacade<T, X> implements Serializable
+{
+   
+   private static final long serialVersionUID = 8710258788495459128L;
+
+   private static final Annotation[] EMPTY_BINDINGS = new Annotation[0];
+   
+   // The binding types the helper operates on
+   private final Set<? extends Annotation> bindings;
+   // The Web Beans manager
+   private final BeanManagerImpl manager;
+   // The type of the operation
+   private final Type type;
+
+   /**
+    * 
+    * @param type The event type
+    * @param manager The Web Beans manager
+    * @param bindings The binding types
+    */
+   protected AbstractFacade(Type type, BeanManagerImpl manager, Set<? extends Annotation> bindings)
+   {
+      this.manager = manager;
+      this.type = type;
+      // Need to make sure the Set is serializable, some sets from Google Collections aren't
+      // TODO Work out how to not do this
+      this.bindings = new HashSet<Annotation>(bindings);
+   }
+
+   /**
+    * Gets a string representation
+    * 
+    * @return A string representation
+    */
+   @Override
+   public String toString()
+   {
+      return "Abstract facade implmentation";
+   }
+   
+   protected Annotation[] mergeInBindings(Annotation... newBindings)
+   {
+      Set<Annotation> result = new HashSet<Annotation>();
+      result.addAll(bindings);
+      for (Annotation newAnnotation : newBindings)
+      {
+         if (!getManager().getServices().get(MetaAnnotationStore.class).getBindingTypeModel(newAnnotation.annotationType()).isValid())
+         {
+            throw new IllegalArgumentException(newAnnotation + " is not a binding for " + this);
+         }
+         if (result.contains(newAnnotation))
+         {
+            throw new IllegalArgumentException(newAnnotation + " is already present in the bindings list for " + this);
+         }
+         result.add(newAnnotation);
+      }
+      return result.toArray(EMPTY_BINDINGS);
+   }
+
+   protected BeanManagerImpl getManager()
+   {
+      return manager.getCurrent();
+   }
+   
+   protected Set<? extends Annotation> getBindings()
+   {
+      return Collections.unmodifiableSet(bindings);
+   }
+   
+   protected Type getType()
+   {
+      return type;
+   }
+
+}
\ No newline at end of file

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceBean.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -27,7 +27,6 @@
 import javax.enterprise.inject.TypeLiteral;
 
 import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.InstanceImpl;
 import org.jboss.webbeans.literal.AnyLiteral;
 import org.jboss.webbeans.resolution.ResolvableTransformer;
 

Copied: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceImpl.java (from rev 3380, ri/trunk/impl/src/main/java/org/jboss/webbeans/InstanceImpl.java)
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceImpl.java	                        (rev 0)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard/InstanceImpl.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -0,0 +1,136 @@
+/*
+ * 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.webbeans.bean.standard;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.enterprise.inject.Instance;
+import javax.enterprise.inject.TypeLiteral;
+import javax.enterprise.inject.spi.Bean;
+
+import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.resolution.ResolvableWBClass;
+
+/**
+ * Helper implementation for Instance for getting instances
+ * 
+ * @author Gavin King
+ * 
+ * @param <T>
+ */
+public class InstanceImpl<T> extends AbstractFacade<T, Instance<T>> implements Instance<T>, Serializable
+{
+
+   private static final long serialVersionUID = -376721889693284887L;
+   private static final Annotation[] EMPTY_BINDINGS = new Annotation[0];
+   
+   private final Set<Bean<?>> beans;
+
+   public static <I> Instance<I> of(Type type, BeanManagerImpl manager, Set<Annotation> annotations)
+   {
+      return new InstanceImpl<I>(type, manager, annotations);
+   }
+   
+   private InstanceImpl(Type type, BeanManagerImpl manager, Set<Annotation> bindings)
+   {
+      super(type, manager, bindings);
+      this.beans = getManager().getBeans(getType(), bindings.toArray(EMPTY_BINDINGS));
+   }
+
+   public T get(Annotation... bindings)
+   {
+      Annotation[] annotations = mergeInBindings(bindings);
+      Bean<T> bean = getManager().getBean(ResolvableWBClass.<T>of(getType(), annotations, getManager()), annotations);
+      
+      @SuppressWarnings("unchecked")
+      T instance = (T) getManager().getReference(bean, getType(), getManager().createCreationalContext(bean));
+      return instance;
+   }
+
+   /**
+    * Gets a string representation
+    * 
+    * @return A string representation
+    */
+   @Override
+   public String toString()
+   {
+      return "Obtainable instance for type " + getType() + " and binding types " + getBindings();
+   }
+
+   private Collection<T> getReferences()
+   {
+      Collection<T> instances = new ArrayList<T>();
+      for (Bean<?> bean : beans)
+      {
+         Object object = getManager().getReference(bean, getType(), getManager().createCreationalContext(bean));
+         
+         @SuppressWarnings("unchecked")
+         T instance = (T) object;
+         
+         instances.add(instance);
+      }
+      return instances;
+   }
+   
+   public Iterator<T> iterator()
+   {
+      return getReferences().iterator();
+   }
+
+   public boolean isAmbiguous()
+   {
+      return beans.size() > 1;
+   }
+
+   public boolean isUnsatisfied()
+   {
+      return beans.size() == 0;
+   }
+
+   public Instance<T> select(Annotation... bindings)
+   {
+      return selectInstance(this.getType(), bindings);
+   }
+
+   public <U extends T> Instance<U> select(Class<U> subtype, Annotation... bindings)
+   {
+      return selectInstance(subtype, bindings);
+   }
+
+   public <U extends T> Instance<U> select(TypeLiteral<U> subtype, Annotation... bindings)
+   {
+      return selectInstance(subtype.getType(), bindings);
+   }
+   
+   private <U extends T> Instance<U> selectInstance(Type subtype, Annotation[] bindings)
+   {
+      return new InstanceImpl<U>(
+            subtype, 
+            this.getManager(), 
+            new HashSet<Annotation>(Arrays.asList(mergeInBindings(bindings))));
+   } 
+
+}

Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/event/EventImpl.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -26,7 +26,7 @@
 import javax.enterprise.inject.TypeLiteral;
 
 import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.FacadeImpl;
+import org.jboss.webbeans.bean.standard.AbstractFacade;
 import org.jboss.webbeans.util.Strings;
 
 /**
@@ -37,7 +37,7 @@
  * @param <T> The type of event being wrapped
  * @see javax.enterprise.event.Event
  */
-public class EventImpl<T> extends FacadeImpl<T> implements Event<T>
+public class EventImpl<T> extends AbstractFacade<T, Event<T>> implements Event<T>
 {
    
    private static final long serialVersionUID = 656782657242515455L;
@@ -55,7 +55,7 @@
     * @param manager The Web Beans manager
     * @param bindings The binding types
     */
-   public EventImpl(Type eventType, BeanManagerImpl manager, Set<Annotation> bindings)
+   private EventImpl(Type eventType, BeanManagerImpl manager, Set<Annotation> bindings)
    {
       super(eventType, manager, bindings);
    }
@@ -74,29 +74,28 @@
    {
       getManager().fireEvent(event, mergeInBindings());
    }
-
+   
    public Event<T> select(Annotation... bindings)
    {
-      return new EventImpl<T>(
-            this.getType(), 
-            this.getManager(), 
-            new HashSet<Annotation>(Arrays.asList(mergeInBindings(bindings))));
+      return selectEvent(this.getType(), bindings);
    }
 
    public <U extends T> Event<U> select(Class<U> subtype, Annotation... bindings)
    {
-      return new EventImpl<U>(
-            subtype, 
-            this.getManager(), 
-            new HashSet<Annotation>(Arrays.asList(mergeInBindings(bindings))));
+      return selectEvent(subtype, bindings);
    }
 
    public <U extends T> Event<U> select(TypeLiteral<U> subtype, Annotation... bindings)
    {
+      return selectEvent(subtype.getType(), bindings);
+   }
+   
+   private <U extends T> Event<U> selectEvent(Type subtype, Annotation[] bindings)
+   {
       return new EventImpl<U>(
-            subtype.getType(), 
+            subtype, 
             this.getManager(), 
             new HashSet<Annotation>(Arrays.asList(mergeInBindings(bindings))));
-   }
+   } 
 
 }

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -24,12 +24,12 @@
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.UnsatisfiedResolutionException;
 
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyLiteral;
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
 import org.jboss.test.audit.annotations.SpecAssertion;
 import org.jboss.test.audit.annotations.SpecAssertions;
 import org.jboss.test.audit.annotations.SpecVersion;
-import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.AnyLiteral;
-import org.jboss.jsr299.tck.literals.CurrentLiteral;
 import org.jboss.testharness.impl.packaging.Artifact;
 import org.testng.annotations.Test;
 
@@ -53,18 +53,16 @@
       assert injectionPoint.getPaymentProcessor() != null;
    }
    
-   @Test(groups = "ri-broken", expectedExceptions = IllegalArgumentException.class)
+   @Test(expectedExceptions = IllegalArgumentException.class)
    @SpecAssertion(section = "5.7.1", id ="da")
-   // WBRI-307
    public void testDuplicateBindingsThrowsException()
    {
       ObtainsInstanceBean injectionPoint = getInstanceByType(ObtainsInstanceBean.class);
       injectionPoint.getAnyPaymentProcessor().select(new CurrentLiteral(), new CurrentLiteral());      
    }      
    
-   @Test(groups = "ri-broken", expectedExceptions = IllegalArgumentException.class)
+   @Test(expectedExceptions = IllegalArgumentException.class)
    @SpecAssertion(section = "5.7.1", id = "e")
-   // WBRI-307
    public void testNonBindingThrowsException()
    {
       ObtainsInstanceBean injectionPoint = getInstanceByType(ObtainsInstanceBean.class);
@@ -89,9 +87,8 @@
       assert instance.get().getValue() == 10;
    }
    
-   @Test(groups = "ri-broken", expectedExceptions = UnsatisfiedResolutionException.class)
+   @Test(expectedExceptions = UnsatisfiedResolutionException.class)
    @SpecAssertion(section = "5.7.1", id = "fba")
-   // WBRI-307
    public void testUnsatisfiedDependencyThrowsException()
    {
       getInstanceByType(ObtainsInstanceBean.class).getPaymentProcessor().select(RemotePaymentProcessor.class).get();
@@ -104,67 +101,75 @@
       getInstanceByType(ObtainsInstanceBean.class).getAnyPaymentProcessor().get();      
    }
    
-   @Test(groups = "ri-broken")
+   @Test
    @SpecAssertions({
       @SpecAssertion(section="5.7.1", id="aa"),
       @SpecAssertion(section="5.7.1", id="ba"),
       @SpecAssertion(section="5.7.1", id="ja"),
       @SpecAssertion(section="5.7.1", id="ka")
    })
-   // WBRI-307
-   public void testIteratorMethod() {
+   public void testIteratorMethod()
+   {
       // initial setup of contextual instances
       getInstanceByType(AdvancedPaymentProcessor.class, new AnyLiteral()).setValue(1);
       getInstanceByType(RemotePaymentProcessor.class, new AnyLiteral()).setValue(2);
-      
+
       Instance<PaymentProcessor> instance = getInstanceByType(ObtainsInstanceBean.class).getAnyPaymentProcessor();
       Iterator<AsynchronousPaymentProcessor> iterator1 = instance.select(AsynchronousPaymentProcessor.class).iterator();
-      
+
       AdvancedPaymentProcessor advanced = null;
       RemotePaymentProcessor remote = null;
       int instances = 0;
-      for (AsynchronousPaymentProcessor processor = iterator1.next(); iterator1.hasNext(); processor = iterator1.next()) {
-         if (processor instanceof AdvancedPaymentProcessor) {
+      while (iterator1.hasNext())
+      {
+         PaymentProcessor processor = iterator1.next();
+         if (processor instanceof AdvancedPaymentProcessor)
+         {
             advanced = (AdvancedPaymentProcessor) processor;
-         } else if (processor instanceof RemotePaymentProcessor) {
+         }
+         else if (processor instanceof RemotePaymentProcessor)
+         {
             remote = (RemotePaymentProcessor) processor;
-         } else {
+         }
+         else
+         {
             throw new RuntimeException("Unexpected instance returned by iterator.");
          }
          instances++;
       }
-      
+
       assert instances == 2;
-      assert (advanced != null) && (advanced.getValue() == 1);
-      assert (remote != null) && (remote.getValue() == 2);
-      
+      assert advanced != null;
+      assert advanced.getValue() == 1;
+      assert remote != null;
+      assert remote.getValue() == 2;
+
       Iterator<RemotePaymentProcessor> iterator2 = instance.select(RemotePaymentProcessor.class, new PayByBinding()
       {
          public PaymentMethod value()
          {
-            return PaymentMethod.CHEQUE;
+            return PaymentMethod.CREDIT_CARD;
          }
       }).iterator();
-      
+
       assert iterator2.next().getValue() == 2;
       assert !iterator2.hasNext();
    }
    
-   @Test(groups= "ri-broken")
+   @Test
    @SpecAssertion(section = "5.7.1", id = "l")
-   // WBRI-307
-   public void testIsUnsatisfied() {
+   public void testIsUnsatisfied()
+   {
       ObtainsInstanceBean injectionPoint = getInstanceByType(ObtainsInstanceBean.class);
       assert !injectionPoint.getAnyPaymentProcessor().isUnsatisfied();
       assert injectionPoint.getPaymentProcessor().select(RemotePaymentProcessor.class).isUnsatisfied();
    }
    
-   @Test(groups= "ri-broken")
+   @Test
    @SpecAssertions({
       @SpecAssertion(section = "5.7", id = "da"),
       @SpecAssertion(section = "5.7.1", id = "m")
    })
-   // WBRI-307
    public void testIsAmbiguous()
    {
       ObtainsInstanceBean injectionPoint = getInstanceByType(ObtainsInstanceBean.class);

Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/RemotePaymentProcessor.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/RemotePaymentProcessor.java	2009-07-31 14:07:51 UTC (rev 3384)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/RemotePaymentProcessor.java	2009-07-31 14:09:49 UTC (rev 3385)
@@ -2,7 +2,10 @@
 
 import javax.enterprise.context.ApplicationScoped;
 
+import org.jboss.jsr299.tck.tests.lookup.dynamic.PayBy.PaymentMethod;
+
 @ApplicationScoped
+ at PayBy(PaymentMethod.CREDIT_CARD)
 class RemotePaymentProcessor implements AsynchronousPaymentProcessor
 {
    private int value = 0;




More information about the weld-commits mailing list