[webbeans-commits] Webbeans SVN: r3389 - ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-31 15:00:50 -0400 (Fri, 31 Jul 2009)
New Revision: 3389
Removed:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
WBRI-208, remove the producer field access as spec now says only static fields on session beans, remove offending tests, add one for static fields :-)
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -24,8 +24,6 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.webbeans.BeanManagerImpl;
-import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
-import org.jboss.webbeans.bean.proxy.Marker;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.util.Names;
@@ -86,20 +84,7 @@
@Override
protected T produceInstance(CreationalContext<T> creationalContext)
{
- Object receiver = getReceiver(creationalContext);
- if (getDeclaringBean() instanceof EnterpriseBean<?> && receiver instanceof EnterpriseBeanInstance)
- {
- EnterpriseBeanInstance declaringInstance = (EnterpriseBeanInstance) receiver;
- Object object = declaringInstance.getSessionObjectReference(Marker.INSTANCE).getFieldValue(field.getDeclaringType().getJavaClass(), field.getName());
-
- @SuppressWarnings("unchecked")
- T instance = (T) object;
- return instance;
- }
- else
- {
- return field.get(receiver);
- }
+ return field.get(getReceiver(creationalContext));
}
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -51,25 +51,4 @@
*/
public void remove();
- /**
- * Retrieve the value of a field. The field may have any visibility modifier.
- *
- * Used for retrieving producer field value.
- *
- * If invoked on an SLSB, Web Beans places no requirements on which bean
- * instance is returned.
- *
- * @param declaringClass the class declaring the field
- * @param fieldName the name of the field
- * @return the current field value
- * @throws IllegalArgumentException if the declaringClass is null
- * @throws IllegalArgumentException if the fieldName is null
- * @throws IllegalArgumentException if the declaring class is not part of the
- * inheritance hierarchy of this session object reference's bean
- * class
- * @throws IllegalArgumentException if the declaringClass represents an
- * interface
- */
- public Object getFieldValue(Class<?> declaringClass, String fieldName);
-
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Chicken.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -6,6 +6,9 @@
@Stateful
public class Chicken implements ChickenLocal
{
+
+ public static final int SIZE = 5;
+
@Produces @Foo
- private Egg egg = new Egg(this);
+ private static Egg egg = new Egg(SIZE);
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/Egg.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -3,17 +3,20 @@
public class Egg
{
- private final Chicken mother;
+ private final int size;
- public Egg(Chicken mother)
+ public Egg(int size)
{
super();
- this.mother = mother;
+ this.size = size;
}
- public Chicken getMother()
+ /**
+ * @return the size
+ */
+ public int getSize()
{
- return mother;
+ return size;
}
}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/EnterpriseProducerFieldDefinitionTest.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1,11 +1,10 @@
package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-import java.lang.annotation.Annotation;
-
import javax.enterprise.inject.AnnotationLiteral;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
import org.jboss.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.IntegrationTest;
@@ -21,21 +20,18 @@
@SpecVersion("20090625")
public class EnterpriseProducerFieldDefinitionTest extends AbstractJSR299Test
{
- private static final Annotation FOO_LITERAL = new AnnotationLiteral<Foo>() {};
- @Test(groups = {"producerField", "ri-broken"})
- @SpecAssertion(section = "4.2", id = "eb")
- // WBRI-208
- public void testNonStaticProducerFieldNotInherited()
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section = "3.4", id = "ab"),
+ @SpecAssertion(section = "3.4", id = "ca")
+ })
+ public void testStaticProducerField()
{
- assert !(getInstanceByType(Egg.class,FOO_LITERAL).getMother() instanceof InfertileChicken);
+ assert getInstanceByType(Egg.class, new AnnotationLiteral<Foo>() {}) != null;
+ assert getInstanceByType(Egg.class, new AnnotationLiteral<Foo>() {}).getSize() == Chicken.SIZE;
}
-
- @Test(groups = {"producerField", "ri-broken"})
- @SpecAssertion(section = "4.2", id = "ed")
- // WBRI-208
- public void testNonStaticProducerFieldNotIndirectlyInherited()
- {
- assert !(getInstanceByType(Egg.class,FOO_LITERAL).getMother() instanceof LameInfertileChicken);
- }
+
+
+
}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChicken.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-public class InfertileChicken extends Chicken implements InfertileChickenLocal
-{
-
-}
\ No newline at end of file
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/InfertileChickenLocal.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-import javax.ejb.Local;
-
-@Local
-public interface InfertileChickenLocal
-{
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChicken.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-import javax.ejb.Stateful;
-
-@Stateful
-public class LameInfertileChicken extends InfertileChicken implements LameInfertileChickenLocal
-{
-
-}
Deleted: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/producer/field/definition/enterprise/LameInfertileChickenLocal.java 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1,9 +0,0 @@
-package org.jboss.jsr299.tck.tests.implementation.producer.field.definition.enterprise;
-
-import javax.ejb.Local;
-
-@Local
-public interface LameInfertileChickenLocal
-{
-
-}
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 15:45:48 UTC (rev 3388)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 19:00:50 UTC (rev 3389)
@@ -1035,6 +1035,10 @@
<assertion id="c">
<text>A producer field may be non-static.</text>
</assertion>
+
+ <assertion id="ca">
+ <text> If the bean is a session bean, the producer field must be a static field of the bean class.</text>
+ </assertion>
<assertion id="d">
<text>If a producer field sometimes contains a null value when accessed, then the producer field must have scope |@Dependent|</text>
@@ -1629,20 +1633,14 @@
<assertion id="ea">
<text>For class X which is extended _directly_ by the bean class of a _managed_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit this field unless Y is explicitly declared to specialize X.</text>
+ <note>We don't test session beans, as they can't have non-static producer fields</note>
</assertion>
- <assertion id="eb">
- <text>For class X which is extended _directly_ by the bean class of a _session_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit this field unless Y is explicitly declared to specialize X.</text>
- </assertion>
-
<assertion id="ec">
<text>For class X which is extended _indirectly_ by the bean class of a _managed_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit this field unless Y is explicitly declared to specialize X.</text>
+ <note>We don't test session beans, as they can't have non-static producer fields</note>
</assertion>
- <assertion id="ed">
- <text>For class X which is extended _indirectly_ by the bean class of a _session_ bean Y, if X declares a _non-static producer field_ x then Y does not inherit this field unless Y is explicitly declared to specialize X.</text>
- </assertion>
-
<assertion id="f">
<text>If X is a generic type, and an injection point declared by X is inherited by Y, and the declared type of the injection point contains type variables declared by X, the type of the injection point inherited in Y is the declared type, after substitution of actual type arguments declared by Y or any intermediate class that is a subclass of X and a superclass of Y.</text>
</assertion>
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3388 - in ri/trunk/impl/src/main/java/org/jboss/webbeans/bean: proxy and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-31 11:45:48 -0400 (Fri, 31 Jul 2009)
New Revision: 3388
Modified:
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
Log:
Wire in use of SessionObjectReference.getFieldValue() in producer fields
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31 14:48:47 UTC (rev 3387)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/ProducerFieldBean.java 2009-07-31 15:45:48 UTC (rev 3388)
@@ -24,6 +24,8 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.webbeans.BeanManagerImpl;
+import org.jboss.webbeans.bean.proxy.EnterpriseBeanInstance;
+import org.jboss.webbeans.bean.proxy.Marker;
import org.jboss.webbeans.bootstrap.BeanDeployerEnvironment;
import org.jboss.webbeans.introspector.WBField;
import org.jboss.webbeans.util.Names;
@@ -84,7 +86,20 @@
@Override
protected T produceInstance(CreationalContext<T> creationalContext)
{
- return field.get(getReceiver(creationalContext));
+ Object receiver = getReceiver(creationalContext);
+ if (getDeclaringBean() instanceof EnterpriseBean<?> && receiver instanceof EnterpriseBeanInstance)
+ {
+ EnterpriseBeanInstance declaringInstance = (EnterpriseBeanInstance) receiver;
+ Object object = declaringInstance.getSessionObjectReference(Marker.INSTANCE).getFieldValue(field.getDeclaringType().getJavaClass(), field.getName());
+
+ @SuppressWarnings("unchecked")
+ T instance = (T) object;
+ return instance;
+ }
+ else
+ {
+ return field.get(receiver);
+ }
}
Modified: ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java
===================================================================
--- ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-07-31 14:48:47 UTC (rev 3387)
+++ ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/proxy/EnterpriseBeanInstance.java 2009-07-31 15:45:48 UTC (rev 3388)
@@ -19,6 +19,7 @@
import javax.enterprise.context.spi.CreationalContext;
import org.jboss.webbeans.bean.EnterpriseBean;
+import org.jboss.webbeans.ejb.api.SessionObjectReference;
/**
* Interface implemented by all enterprise bean proxies to query/control the proxy
@@ -40,4 +41,6 @@
public void destroy(Marker marker, EnterpriseBean<?> enterpriseBean, CreationalContext<?> creationalContext);
+ public SessionObjectReference getSessionObjectReference(Marker marker);
+
}
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3387 - ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-31 10:48:47 -0400 (Fri, 31 Jul 2009)
New Revision: 3387
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
Log:
Note about SLSBs
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31 14:45:51 UTC (rev 3386)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31 14:48:47 UTC (rev 3387)
@@ -56,6 +56,9 @@
*
* Used for retrieving producer field value.
*
+ * If invoked on an SLSB, Web Beans places no requirements on which bean
+ * instance is returned.
+ *
* @param declaringClass the class declaring the field
* @param fieldName the name of the field
* @return the current field value
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3386 - in ri/trunk: tests/src/main/java/org/jboss/webbeans/mock and 1 other directory.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-31 10:45:51 -0400 (Fri, 31 Jul 2009)
New Revision: 3386
Modified:
ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
Log:
add proposed spi for accessing producer field values on EJBs
Modified: ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java
===================================================================
--- ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31 14:09:49 UTC (rev 3385)
+++ ri/trunk/spi/src/main/java/org/jboss/webbeans/ejb/api/SessionObjectReference.java 2009-07-31 14:45:51 UTC (rev 3386)
@@ -18,6 +18,8 @@
import java.io.Serializable;
+import javax.ejb.NoSuchEJBException;
+
/**
* A serializable reference to a session object in the EJB container
*
@@ -25,33 +27,46 @@
*/
public interface SessionObjectReference extends Serializable
{
-
+
/**
- * Get the reference from the EJB container to the session object for the
+ * Get the reference from the EJB container to the session object for the
* given business interface
*
- * @param <S>
- * the type of the business interface
- * @param businessInterfaceType
- * the type of the business interface
+ * @param <S> the type of the business interface
+ * @param businessInterfaceType the type of the business interface
* @return a reference
*
- * @throws IllegalStateException
- * if the business interface is not a local business interface of
- * the session bean
- * @throws NoSuchEJBException
- * if the session object has already been removed
+ * @throws IllegalStateException if the business interface is not a local
+ * business interface of the session bean
+ * @throws NoSuchEJBException if the session object has already been removed
*/
public <S> S getBusinessObject(Class<S> businessInterfaceType);
-
+
/**
* Request the EJB container remove the stateful session object
*
- * @throws UnsupportedOperationException
- * if the reference is not backed by a stateful session object
- * @throws NoSuchEJBException
- * if the session object has already been removed
+ * @throws UnsupportedOperationException if the reference is not backed by a
+ * stateful session object
+ * @throws NoSuchEJBException if the session object has already been removed
*/
public void remove();
-
+
+ /**
+ * Retrieve the value of a field. The field may have any visibility modifier.
+ *
+ * Used for retrieving producer field value.
+ *
+ * @param declaringClass the class declaring the field
+ * @param fieldName the name of the field
+ * @return the current field value
+ * @throws IllegalArgumentException if the declaringClass is null
+ * @throws IllegalArgumentException if the fieldName is null
+ * @throws IllegalArgumentException if the declaring class is not part of the
+ * inheritance hierarchy of this session object reference's bean
+ * class
+ * @throws IllegalArgumentException if the declaringClass represents an
+ * interface
+ */
+ public Object getFieldValue(Class<?> declaringClass, String fieldName);
+
}
Modified: ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java
===================================================================
--- ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-07-31 14:09:49 UTC (rev 3385)
+++ ri/trunk/tests/src/main/java/org/jboss/webbeans/mock/MockEjBServices.java 2009-07-31 14:45:51 UTC (rev 3386)
@@ -3,7 +3,6 @@
*/
package org.jboss.webbeans.mock;
-import java.lang.reflect.Field;
import java.util.Collection;
import javax.enterprise.inject.spi.InjectionPoint;
@@ -47,7 +46,7 @@
}
- public Object getFieldValue(Field field)
+ public Object getFieldValue(Class<?> declaringClass, String fieldName)
{
// TODO Auto-generated method stub
return null;
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3385 - ri/trunk/impl/src/main/java/org/jboss/webbeans/bean/standard and 2 other directories.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)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
+(a)PayBy(PaymentMethod.CREDIT_CARD)
class RemotePaymentProcessor implements AsynchronousPaymentProcessor
{
private int value = 0;
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3384 - tck/trunk/doc/reference/en-US.
by webbeans-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2009-07-31 10:07:51 -0400 (Fri, 31 Jul 2009)
New Revision: 3384
Modified:
tck/trunk/doc/reference/en-US/Book_Preface.xml
tck/trunk/doc/reference/en-US/appeals-process.xml
tck/trunk/doc/reference/en-US/introduction.xml
tck/trunk/doc/reference/en-US/reporting.xml
Log:
A few updates
Modified: tck/trunk/doc/reference/en-US/Book_Preface.xml
===================================================================
--- tck/trunk/doc/reference/en-US/Book_Preface.xml 2009-07-31 13:52:43 UTC (rev 3383)
+++ tck/trunk/doc/reference/en-US/Book_Preface.xml 2009-07-31 14:07:51 UTC (rev 3384)
@@ -86,6 +86,13 @@
</listitem>
<listitem>
<para>
+ <xref linkend="appeals-process" />
+ explains the process to be followed by an implementor should they
+ wish to challenge any test in the TCK.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
<xref linkend="installation" />
explains where to obtain the required software for the CDI TCK
and how to install it. It covers both the primary TCK components
Modified: tck/trunk/doc/reference/en-US/appeals-process.xml
===================================================================
--- tck/trunk/doc/reference/en-US/appeals-process.xml 2009-07-31 13:52:43 UTC (rev 3383)
+++ tck/trunk/doc/reference/en-US/appeals-process.xml 2009-07-31 14:07:51 UTC (rev 3384)
@@ -24,8 +24,7 @@
central aspect of any good software and it's only natural to point out
shortcomings and strive to make improvements. Despite this good faith,
not all implementors will be comfortable with a public appeals process.
- Therefore, further instructions will be forthcoming about how to make a
- private appeal.
+ Instructions about how to make a private appeal are therefore provided.
</para>
<section>
<title>Who can make challenges to the TCK?</title>
@@ -67,13 +66,19 @@
url="http://www.jboss.org/index.html?op=checkage&module=user">on-line
registration</ulink>.
</para>
+ <para>
+ If you wish to make a private challenge, you should follow the above
+ procedure, setting the Security Level to Private. Only the issue
+ reporter, TCK Project Lead and designates will be able to view the
+ issue.
+ </para>
</section>
<section>
<title>How and by whom challenges are addressed?</title>
<para>
The challenges will be addressed in a timely fashion by the CDI TCK
Project Lead, as designated by Specification Lead, Red Hat Middleware
- LLC. or his/her appointee. The appellant can also monitor the process
+ LLC. or his/her designate. The appellant can also monitor the process
by following the issue report filed in the <ulink
url="https://jira.jboss.org/jira/browse/WBTCK">WBTCK project</ulink>
of the JBoss JIRA.
@@ -99,7 +104,7 @@
Resolved issue not addressed for 30 days will be closed by the TCK
Project Lead. If the TCK Project Lead and appellant are unable to
agree on the issue resolution, it will be referred to the JSR-299
- specification lead or his/her desginate.
+ specification lead or his/her designate.
</para>
</section>
</chapter>
Modified: tck/trunk/doc/reference/en-US/introduction.xml
===================================================================
--- tck/trunk/doc/reference/en-US/introduction.xml 2009-07-31 13:52:43 UTC (rev 3383)
+++ tck/trunk/doc/reference/en-US/introduction.xml 2009-07-31 14:07:51 UTC (rev 3384)
@@ -270,29 +270,22 @@
<para>
Sun Microsystems, Inc. will implement the porting package for the
CDI RI and test the CDI RI on the Java EE Reference
- Implementation.
+ Implementation as well as other platforms.
</para>
</note>
- <para>
- The CDI TCK has been tested with the following:
- </para>
+ <para>The CDI TCK has been tested run on following platforms:</para>
<itemizedlist>
<listitem>
- <para>JBoss AS 5.1.0.GA</para>
+ <para>
+ JBoss AS 5.1.0.GA using Sun Java SE 6 on Red Hat Enterprise
+ Linux 5.2
+ </para>
</listitem>
</itemizedlist>
- <para>The CDI TCK tests run on the following platforms:</para>
- <itemizedlist>
- <listitem>
- <para>Red Hat Enterprise Linux 5.2</para>
- </listitem>
- </itemizedlist>
<para>
CDI supports Java EE 5, Java EE 6, Java EE 6 Web Profile and the
- Embeddable EJB 3.1. The TCK will run on any of these runtimes, but
- is only part of the CTS for Java EE 6, Java EE 6 Web Profile and
- Embeddable EJB 3.1 (SUN: Please confirm these are the CTS the CDI
- TCK will run in).
+ Embeddable EJB 3.1. The TCK will execute on any of these runtimes,
+ but is only part of the CTS for Java EE 6 and Java EE 6 Web Profile.
</para>
</section>
</section>
Modified: tck/trunk/doc/reference/en-US/reporting.xml
===================================================================
--- tck/trunk/doc/reference/en-US/reporting.xml 2009-07-31 13:52:43 UTC (rev 3383)
+++ tck/trunk/doc/reference/en-US/reporting.xml 2009-07-31 14:07:51 UTC (rev 3384)
@@ -8,7 +8,66 @@
chapter also justifies why the TCK is good indicator of how accurately an
implementation conforms to the JSR-299 specification.
</para>
+
<section>
+ <title>CDI TCK Coverage Metrics</title>
+
+ <para>
+ The CDI TCK coverage has been measured as follows:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ <emphasis role="bold">Assertion Breadth Coverage</emphasis>
+ </para>
+ <para>
+ The CDI TCK provides at least 75% coverage of identified
+ assertions with test cases.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="bold">Assertion Breadth Coverage Variance</emphasis>
+ </para>
+ <para>
+ The coverage of specification sub-sections shows at least a
+ normal distribution (centered around 75%).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="bold">Assertion Depth Coverage</emphasis>
+ </para>
+ <para>
+ The assertion depth coverage has not been measured, as, when an
+ assertion requires more than one testcase, these have been
+ enumerated in an assertion group and so are adequately described
+ by the assertion breadth coverage.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="bold">Method Coverage</emphasis>
+ </para>
+ <para>
+ TODO
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ <emphasis role="bold">API Signature Coverage</emphasis>
+ </para>
+ <para>
+ The CDI TCK covers 100% of all API public methods using the Java
+ CTT Sig Test tool.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ </section>
+
+ <section>
<title>CDI TCK Coverage Report</title>
<para>
A specification can be distilled into a collection of assertions that
@@ -66,11 +125,6 @@
}]]></programlisting>
<para>
- The CDI TCK matches tests to 75% of these assertions, which is
- proposed as sufficient coverage to certify a CDI implementation.
- </para>
-
- <para>
To help evaluate the distribution of coverage for these assertions,
the TCK provides a detailed coverage report. This report is also
useful to help implementors match tests with the language in the
@@ -151,16 +205,30 @@
<itemizedlist>
<listitem>
- <para>Covered</para>
+ <para>
+ <emphasis role="bold">Covered</emphasis> - a test exists for this
+ assertion
+ </para>
</listitem>
<listitem>
- <para>Not covered</para>
+ <para>
+ <emphasis role="bold">Not covered</emphasis> - no test exists for this
+ assertion
+ </para>
</listitem>
<listitem>
- <para>Unimplemented</para>
+ <para>
+ <emphasis role="bold">Problematic</emphasis> - a test exists, but is
+ currently disabled. For example, this may be because the test
+ is under development
+ </para>
</listitem>
<listitem>
- <para>Untestable</para>
+ <para>
+ <emphasis role="bold">Untestable</emphasis> - the assertion has been
+ deemed untestable, a note, explaining why, is normally
+ provided
+ </para>
</listitem>
</itemizedlist>
@@ -180,11 +248,10 @@
<title>TestNG Reports</title>
<para>
- As you know well by now, the CDI TCK test suite is really just a
- TestNG test suite. That means an execution of the CDI TCK test
- suite produces all the same reports that TestNG produces. This
- section will go over those reports and show you were to go
- to find each of them.
+ As you by now, the CDI TCK test suite is really just a TestNG test
+ suite. That means an execution of the CDI TCK test suite produces
+ all the same reports that TestNG produces. This section will go over
+ those reports and show you were to go to find each of them.
</para>
<section>
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3383 - tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic.
by webbeans-commits@lists.jboss.org
Author: jharting
Date: 2009-07-31 09:52:43 -0400 (Fri, 31 Jul 2009)
New Revision: 3383
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java
Log:
Fixed test
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 11:03:08 UTC (rev 3382)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dynamic/DynamicLookupTest.java 2009-07-31 13:52:43 UTC (rev 3383)
@@ -94,7 +94,7 @@
// WBRI-307
public void testUnsatisfiedDependencyThrowsException()
{
- getInstanceByType(ObtainsInstanceBean.class).getPaymentProcessor().select(AdvancedPaymentProcessor.class).get();
+ getInstanceByType(ObtainsInstanceBean.class).getPaymentProcessor().select(RemotePaymentProcessor.class).get();
}
@Test(expectedExceptions = AmbiguousResolutionException.class)
@@ -156,7 +156,7 @@
public void testIsUnsatisfied() {
ObtainsInstanceBean injectionPoint = getInstanceByType(ObtainsInstanceBean.class);
assert !injectionPoint.getAnyPaymentProcessor().isUnsatisfied();
- assert injectionPoint.getPaymentProcessor().select(AdvancedPaymentProcessor.class).isUnsatisfied();
+ assert injectionPoint.getPaymentProcessor().select(RemotePaymentProcessor.class).isUnsatisfied();
}
@Test(groups= "ri-broken")
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3382 - tck/trunk.
by webbeans-commits@lists.jboss.org
Author: jharting
Date: 2009-07-31 07:03:08 -0400 (Fri, 31 Jul 2009)
New Revision: 3382
Modified:
tck/trunk/pom.xml
Log:
Added myself to <developers/>
Modified: tck/trunk/pom.xml
===================================================================
--- tck/trunk/pom.xml 2009-07-31 10:33:46 UTC (rev 3381)
+++ tck/trunk/pom.xml 2009-07-31 11:03:08 UTC (rev 3382)
@@ -28,6 +28,12 @@
<developer>
<name>Nicklas Karlsson</name>
</developer>
+
+ <developer>
+ <name>Jozef Hartinger</name>
+ <email>jharting(a)redhat.com</email>
+ <organization>JBoss, a division of Red Hat</organization>
+ </developer>
</developers>
<repositories>
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3381 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/policy and 1 other directories.
by webbeans-commits@lists.jboss.org
Author: jharting
Date: 2009-07-31 06:33:46 -0400 (Fri, 31 Jul 2009)
New Revision: 3381
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
Split assertions
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java 2009-07-31 09:19:46 UTC (rev 3380)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/injectionpoint/InjectionPointTest.java 2009-07-31 10:33:46 UTC (rev 3381)
@@ -159,7 +159,7 @@
}
@Test(groups = { "injectionPoint" })
- @SpecAssertion(section = "5.6.9", id = "e")
+ @SpecAssertion(section = "5.6.9", id = "ea")
public void testDependentScope()
{
assert getBeans(InjectionPoint.class).size() == 1;
@@ -168,7 +168,7 @@
@Test(groups = { "injectionPoint" })
@SpecAssertions({
- @SpecAssertion(section = "5.6.9", id = "e")
+ @SpecAssertion(section = "5.6.9", id = "ea")
})
public void testApiTypeInjectionPoint()
{
@@ -181,7 +181,7 @@
@Test(groups = { "injectionPoint" })
@SpecAssertions({
- @SpecAssertion(section = "5.6.9", id = "e")
+ @SpecAssertion(section = "5.6.9", id = "ea")
})
public void testCurrentBinding()
{
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java 2009-07-31 09:19:46 UTC (rev 3380)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/policy/PolicyAvailabilityTest.java 2009-07-31 10:33:46 UTC (rev 3381)
@@ -68,7 +68,7 @@
}
@Test(groups = {"policy", "ri-broken"})
- @SpecAssertion(section = "5.2", id = "f")
+ @SpecAssertion(section = "5.2", id = "fa")
// WBRI-306
public void testProducerPolicies() throws Exception
{
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 09:19:46 UTC (rev 3380)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 10:33:46 UTC (rev 3381)
@@ -1798,9 +1798,17 @@
<text>A policy is enabled for the bean deployment archive if the policy is a ~managed bean~ or _session bean_ and the bean class of the bean is listed.</text>
</assertion>
- <assertion id="f">
- <text>A policy is enabled for the bean deployment archive if the policy is a producer method, field or resource, and the bean class that declares the method or field is listed.</text>
- </assertion>
+ <group>
+ <text>A policy is enabled for the bean deployment archive if the policy is a producer method, field or resource, and the bean class that declares the method or field is listed.</text>
+
+ <assertion id="fa">
+ <text>Test for enablement of a producer method and field.</text>
+ </assertion>
+
+ <assertion id="fb">
+ <text>Test for enablement of a resource.</text>
+ </assertion>
+ </group>
<assertion id="g">
<text>A policy is enabled for the bean deployment archive if any |@Policy| stereotype of the policy is listed.</text>
@@ -2239,10 +2247,14 @@
<text>The |isTransient()| method returns true if the injection point is a transient field, and false otherwise.</text>
</assertion>
- <assertion id="e">
- <text>The container must provide a bean with scope |@Dependent|, bean type |InjectionPoint| and binding |@Current|, allowing dependent objects, as defined in Section 6.4.2, "Dependent objects", to obtain information about the injection point to which they belong. The built-in implementation must be a passivation capable dependency, as defined in Section 6.6.2, "Passivation capable dependencies".</text>
+ <assertion id="ea">
+ <text>The container must provide a bean with scope |@Dependent|, bean type |InjectionPoint| and binding |@Current|, allowing dependent objects, as defined in Section 6.4.2, "Dependent objects", to obtain information about the injection point to which they belong.</text>
</assertion>
+ <assertion id="eb">
+ <text>The built-in implementation must be a passivation capable dependency, as defined in Section 6.6.2, "Passivation capable dependencies".</text>
+ </assertion>
+
<assertion id="f">
<text>If a bean that declares any scope other than |@Dependent| has an injection point of type |InjectionPoint| and binding |@Current|, the container automatically detects the problem and treats it as a definition error, as defined in Section 12.4, "Problems detected automatically by the container".</text>
</assertion>
15 years, 3 months
[webbeans-commits] Webbeans SVN: r3380 - in tck/trunk/impl/src/main: java/org/jboss/jsr299/tck/tests/extensions/beanManager and 4 other directories.
by webbeans-commits@lists.jboss.org
Author: dallen6
Date: 2009-07-31 05:19:46 -0400 (Fri, 31 Jul 2009)
New Revision: 3380
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cat.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/CatBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/DerivedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/SimpleBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Tame.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/HierarchyDiscovery.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/ParameterizedTypeImpl.java
Modified:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/ResolutionByNameTest.java
tck/trunk/impl/src/main/resources/tck-audit.xml
Log:
Added more tests for Ch. 11
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,64 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.jsr299.tck.tests.extensions.beanManager;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.test.audit.annotations.SpecAssertion;
+import org.jboss.test.audit.annotations.SpecVersion;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+/**
+ * Mostly tests for extensions specified in chapter 11 of the specification
+ * and not already tested elsewhere.
+ *
+ * @author David Allen
+ *
+ */
+@Artifact
+@SpecVersion("20090625")
+public class BeanManagerTest extends AbstractJSR299Test
+{
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "11.3.7", id = "a")
+ //WBRI-328
+ public void testGetPassivationCapableBeanById()
+ {
+ Bean<?> bean = getCurrentManager().getBeans(Cat.class).iterator().next();
+ assert PassivationCapable.class.isAssignableFrom(bean.getClass());
+ Bean<?> passivatingBean = getCurrentManager().getPassivationCapableBean(CatBean.bean.getId());
+ assert bean == passivatingBean;
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "11.3.8", id = "a")
+ //WBRI-331
+ public void testAmbiguousDependencyResolved()
+ {
+ Set<Bean<?>> beans = new HashSet<Bean<?>>();
+ beans.addAll(getCurrentManager().getBeans(SimpleBean.class));
+ beans.addAll(getCurrentManager().getBeans(DerivedBean.class));
+ getCurrentManager().resolve(beans);
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/BeanManagerTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cat.java (from rev 3364, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/Cat.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cat.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Cat.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.extensions.beanManager;
+
+class Cat
+{
+
+ @SuppressWarnings("unused")
+ private String name;
+
+ public Cat(String name)
+ {
+ this.name = name;
+ }
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/CatBean.java (from rev 3364, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/definition/bean/custom/CatBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/CatBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/CatBean.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,101 @@
+package org.jboss.jsr299.tck.tests.extensions.beanManager;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+
+import org.jboss.jsr299.tck.literals.CurrentLiteral;
+
+class CatBean implements Bean<Cat>, PassivationCapable
+{
+ public static final CatBean bean = new CatBean();
+
+ @SuppressWarnings("serial")
+ public Set<Annotation> getBindings()
+ {
+ return new HashSet<Annotation>(){{ add(new CurrentLiteral());}};
+ }
+
+ public Class<? extends Annotation> getDeploymentType()
+ {
+ return null;
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return new HashSet<InjectionPoint>();
+ }
+
+ public String getName()
+ {
+ return "cat";
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes() {
+ return new HashSet<Class<? extends Annotation>>();
+ }
+
+ public Class<? extends Annotation> getScopeType()
+ {
+ return Dependent.class;
+ }
+
+ @SuppressWarnings("serial")
+ public Set<Type> getTypes()
+ {
+ return new HashSet<Type>() {{ add(Cat.class); add(Object.class); }};
+ }
+
+ public boolean isNullable()
+ {
+ return false;
+ }
+
+ public boolean isSerializable()
+ {
+ return false;
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return Cat.class;
+ }
+
+ public boolean isPolicy()
+ {
+ return false;
+ }
+
+ public Cat create(CreationalContext<Cat> creationalContext)
+ {
+ return new Cat("kitty");
+ }
+
+ public void destroy(Cat instance, CreationalContext<Cat> creationalContext)
+ {
+ creationalContext.release();
+ }
+
+ public static CatBean getBean()
+ {
+ return bean;
+ }
+
+ public void afterDiscovery(@Observes AfterBeanDiscovery event) {
+ event.addBean(bean);
+ }
+
+ public String getId()
+ {
+ return "org.jboss.jsr299.tck.tests.extensions.beanManager.CatBean";
+ }
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/DerivedBean.java (from rev 3364, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/bean/bytype/DerivedBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/DerivedBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/DerivedBean.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.extensions.beanManager;
+
+import javax.enterprise.inject.Specializes;
+
+@Specializes @Tame
+class DerivedBean extends SimpleBean
+{
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/SimpleBean.java (from rev 3364, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/bean/bytype/SimpleBean.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/SimpleBean.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/SimpleBean.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.extensions.beanManager;
+
+class SimpleBean
+{
+
+}
Copied: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Tame.java (from rev 3364, tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/bean/bytype/Tame.java)
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Tame.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/beanManager/Tame.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.extensions.beanManager;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+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.enterprise.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+@interface Tame
+{
+
+}
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-07-31 09:08:59 UTC (rev 3379)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/simple/lifecycle/SimpleBeanLifecycleTest.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -86,7 +86,10 @@
}
@Test(groups = { "specialization" })
- @SpecAssertion(section = "3.1.5", id = "aa")
+ @SpecAssertions({
+ @SpecAssertion(section = "3.1.5", id = "aa"),
+ @SpecAssertion(section = "11.3.6", id = "a")
+ })
public void testSpecializedBeanExtendsManagedBean()
{
assert MountainLion.class.getAnnotation(Specializes.class) != null;
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/HierarchyDiscovery.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/HierarchyDiscovery.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/HierarchyDiscovery.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,157 @@
+package org.jboss.jsr299.tck.tests.interceptors.definition;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.util.HashSet;
+import java.util.Set;
+
+public class HierarchyDiscovery
+{
+ private final Type type;
+
+ private Set<Type> types;
+
+ public HierarchyDiscovery(Type type)
+ {
+ this.type = type;
+ }
+
+ protected void add(Type type)
+ {
+ types.add(type);
+ }
+
+ public Set<Type> getFlattenedTypes()
+ {
+ if (types == null)
+ {
+ this.types = new HashSet<Type>();
+ discoverTypes(type);
+ }
+ return types;
+ }
+
+ public Type getResolvedType()
+ {
+ return resolveType(type, type);
+ }
+
+ private void discoverTypes(Type type)
+ {
+ if (type != null)
+ {
+ add(type);
+ if (type instanceof Class)
+ {
+ discoverFromClass((Class<?>) type);
+ }
+ else if (type instanceof ParameterizedType)
+ {
+ Type rawType = ((ParameterizedType) type).getRawType();
+ if (rawType instanceof Class)
+ {
+ discoverFromClass((Class<?>) rawType);
+ }
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ private void discoverFromClass(Class<?> clazz)
+ {
+ discoverTypes(resolveType(type, clazz.getGenericSuperclass()));
+ for (Type c : clazz.getGenericInterfaces())
+ {
+ discoverTypes(resolveType(type, c));
+ }
+ }
+
+ /**
+ * Gets the actual types by resolving TypeParameters.
+ *
+ * @param beanType
+ * @param type
+ * @return actual type
+ */
+ private Type resolveType(Type beanType, Type type)
+ {
+ if (type instanceof ParameterizedType)
+ {
+ if (beanType instanceof ParameterizedType)
+ {
+ return resolveParameterizedType((ParameterizedType) beanType, (ParameterizedType) type);
+ }
+ if (beanType instanceof Class)
+ {
+ return resolveType(((Class<?>) beanType).getGenericSuperclass(), type);
+ }
+ }
+
+ if (type instanceof TypeVariable)
+ {
+ if (beanType instanceof ParameterizedType)
+ {
+ return resolveTypeParameter((ParameterizedType) beanType, (TypeVariable<?>) type);
+ }
+ if (beanType instanceof Class)
+ {
+ return resolveType(((Class<?>) beanType).getGenericSuperclass(), type);
+ }
+ }
+ return type;
+ }
+
+ private Type resolveParameterizedType(ParameterizedType beanType, ParameterizedType parameterizedType)
+ {
+ Type rawType = parameterizedType.getRawType();
+ Type[] actualTypes = parameterizedType.getActualTypeArguments();
+
+ Type resolvedRawType = resolveType(beanType, rawType);
+ Type[] resolvedActualTypes = new Type[actualTypes.length];
+
+ for (int i = 0; i < actualTypes.length; i++)
+ {
+ resolvedActualTypes[i] = resolveType(beanType, actualTypes[i]);
+ }
+ // reconstruct ParameterizedType by types resolved TypeVariable.
+ return new ParameterizedTypeImpl(resolvedRawType, resolvedActualTypes, parameterizedType.getOwnerType());
+ }
+
+ private Type resolveTypeParameter(ParameterizedType beanType, TypeVariable<?> typeVariable)
+ {
+ // step1. raw type
+ Class<?> actualType = (Class<?>) beanType.getRawType();
+ TypeVariable<?>[] typeVariables = actualType.getTypeParameters();
+ Type[] actualTypes = beanType.getActualTypeArguments();
+ for (int i = 0; i < typeVariables.length; i++)
+ {
+ if (typeVariables[i].equals(typeVariable))
+ {
+ return resolveType(type, actualTypes[i]);
+ }
+ }
+
+ // step2. generic super class
+ Type genericSuperType = actualType.getGenericSuperclass();
+ Type type = resolveType(genericSuperType, typeVariable);
+ if (!(type instanceof TypeVariable<?>))
+ {
+ return type;
+ }
+
+ // step3. generic interfaces
+ for (Type interfaceType : actualType.getGenericInterfaces())
+ {
+ Type resolvedType = resolveType(interfaceType, typeVariable);
+ if (!(resolvedType instanceof TypeVariable<?>))
+ {
+ return resolvedType;
+ }
+ }
+
+ // don't resolve type variable
+ return typeVariable;
+ }
+
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/HierarchyDiscovery.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java 2009-07-31 09:08:59 UTC (rev 3379)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/InterceptorDefinitionTest.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -18,13 +18,15 @@
package org.jboss.jsr299.tck.tests.interceptors.definition;
import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
import javax.enterprise.inject.spi.Interceptor;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
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.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -47,7 +49,7 @@
public void testInterceptorsImplementInterceptorInterface()
{
boolean interfaceFound = false;
- for (Type type : getBeans(Interceptor1.class).iterator().next().getTypes())
+ for (Type type : getInterfacesImplemented(getBeans(Interceptor1.class).iterator().next().getClass()))
{
if (type.equals(Interceptor.class))
{
@@ -57,4 +59,11 @@
}
assert interfaceFound;
}
+
+ private Set<Type> getInterfacesImplemented(Class<?> clazz)
+ {
+ Set<Type> interfaces = new HashSet<Type>();
+ interfaces.addAll(new HierarchyDiscovery(clazz).getFlattenedTypes());
+ return interfaces;
+ }
}
Added: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/ParameterizedTypeImpl.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/ParameterizedTypeImpl.java (rev 0)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/ParameterizedTypeImpl.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jboss.jsr299.tck.tests.interceptors.definition;
+
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+
+public class ParameterizedTypeImpl implements ParameterizedType
+{
+ private final Type[] actualTypeArguments;
+ private final Type rawType;
+ private final Type ownerType;
+
+ public ParameterizedTypeImpl(Type rawType, Type[] actualTypeArguments, Type ownerType)
+ {
+ this.actualTypeArguments = actualTypeArguments;
+ this.rawType = rawType;
+ this.ownerType = ownerType;
+ }
+
+ public Type[] getActualTypeArguments()
+ {
+ return actualTypeArguments;
+ }
+
+ public Type getOwnerType()
+ {
+ return ownerType;
+ }
+
+ public Type getRawType()
+ {
+ return rawType;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return Arrays.hashCode(actualTypeArguments) ^ (ownerType == null ? 0 : ownerType.hashCode()) ^ (rawType == null ? 0 : rawType.hashCode());
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ else if (obj instanceof ParameterizedType)
+ {
+ ParameterizedType that = (ParameterizedType) obj;
+ Type thatOwnerType = that.getOwnerType();
+ Type thatRawType = that.getRawType();
+ return (ownerType == null ? thatOwnerType == null : ownerType.equals(thatOwnerType)) && (rawType == null ? thatRawType == null : rawType.equals(thatRawType)) && Arrays.equals(actualTypeArguments, that.getActualTypeArguments());
+ }
+ else
+ {
+ return false;
+ }
+
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append(rawType);
+ if (actualTypeArguments.length > 0)
+ {
+ sb.append("<");
+ for (Type actualType : actualTypeArguments)
+ {
+ sb.append(actualType);
+ sb.append(",");
+ }
+ sb.delete(sb.length() - 1, sb.length());
+ sb.append(">");
+ }
+ return sb.toString();
+ }
+}
Property changes on: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/interceptors/definition/ParameterizedTypeImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/ResolutionByNameTest.java
===================================================================
--- tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/ResolutionByNameTest.java 2009-07-31 09:08:59 UTC (rev 3379)
+++ tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/byname/ResolutionByNameTest.java 2009-07-31 09:19:46 UTC (rev 3380)
@@ -16,9 +16,10 @@
*/
package org.jboss.jsr299.tck.tests.lookup.byname;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
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.testharness.impl.packaging.Artifact;
import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -30,7 +31,11 @@
{
@Test(groups = { "resolution" , "ri-broken"})
- @SpecAssertion(section = "5.4.1", id = "c")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.4.1", id = "c"),
+ @SpecAssertion(section = "11.3.5", id = "aa"),
+ @SpecAssertion(section = "11.3.5", id = "b")
+ })
// WBRI-306
public void testAmbiguousELNamesResolved() throws Exception
{
Modified: tck/trunk/impl/src/main/resources/tck-audit.xml
===================================================================
--- tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 09:08:59 UTC (rev 3379)
+++ tck/trunk/impl/src/main/resources/tck-audit.xml 2009-07-31 09:19:46 UTC (rev 3380)
@@ -4298,6 +4298,7 @@
<assertion id="e">
<text>Any operation of |BeanManager| may be called at any time during the execution of the application.</text>
+ <note>This does not appear to be testable</note>
</assertion>
</section>
15 years, 3 months