Author: jharting
Date: 2009-10-21 10:59:56 -0400 (Wed, 21 Oct 2009)
New Revision: 4211
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedConstructorWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedFieldWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedMethodWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedParameterWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedTypeWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Bread.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Cheap.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/CheapLiteral.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Expensive.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ExpensiveLiteral.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Fruit.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Grocery.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptorBinding.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryWrapper.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Milk.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/NamedStereotype.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ProcessAnnotatedTypeObserver.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Shop.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/TropicalFruit.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Vegetables.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Water.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Yogurt.java
Removed:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Bread.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Cheap.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/CheapLiteral.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Expensive.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ExpensiveLiteral.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Fruit.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Grocery.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryAnnotatedType.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptorBinding.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Milk.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/NamedStereotype.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Shop.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedConstructor.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedField.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedMethod.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedParameter.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TropicalFruit.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Vegetables.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Water.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Yogurt.java
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeObserver.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedType.java
Log:
Tests for section 11.4
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AlternativeMetadataTest.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,195 @@
+/*
+ * 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.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.enterprise.context.RequestScoped;
+
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.jsr299.tck.literals.AnyLiteral;
+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;
+import org.jboss.testharness.impl.packaging.Resource;
+import org.jboss.testharness.impl.packaging.Resources;
+import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
+import org.testng.annotations.Test;
+
+/**
+ * This test class contains tests for adding meta data using extensions.
+ * @author Jozef Hartinger
+ *
+ */
+
+@Artifact
+(a)BeansXml("beans.xml")
+@Resources({
+ @Resource(source="javax.enterprise.inject.spi.Extension",
destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
+})
+@IntegrationTest
+@SpecVersion(spec="cdi", version="PFD2")
+public class AlternativeMetadataTest extends AbstractJSR299Test
+{
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "11.4", id = "h")
+ // WELD-200
+ public void testGetBaseTypeUsedToDetermineTypeOfInjectionPoing() {
+ // The base type of the fruit injection point is overridden to TropicalFruit
+ assert GroceryWrapper.isGetBaseTypeOfFruitFieldUsed();
+ assert getInstanceByType(Grocery.class, new
AnyLiteral()).getFruit().getMetadata().getType().equals(TropicalFruit.class);
+ }
+
+ @Test(groups = "ri-broken")
+ @SpecAssertion(section = "11.4", id = "k")
+ // WELD-201
+ public void testGetTypeClosureUsed() {
+ assert GroceryWrapper.isGetTypeClosureUsed();
+ // should be [Object, Grocery] instead of [Object, Shop, Grocery]
+ assert getBeans(Grocery.class, new
AnyLiteral()).iterator().next().getTypes().size() == 2;
+ assert getBeans(Shop.class, new AnyLiteral()).size() == 0;
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "l")
+ public void testGetAnnotationUsedForGettingScopeInformation() {
+ // @ApplicationScoped is overridden by @RequestScoped
+ assert getBeans(Grocery.class, new
AnyLiteral()).iterator().next().getScope().equals(RequestScoped.class);
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "m")
+ public void testGetAnnotationUsedForGettingQualifierInformation() {
+ // @Expensive is overridden by @Cheap
+ assert getBeans(Grocery.class, new CheapLiteral()).size() == 1;
+ assert getBeans(Grocery.class, new ExpensiveLiteral()).size() == 0;
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "n")
+ public void testGetAnnotationUsedForGettingStereotypeInformation() {
+ // The extension adds a stereotype with @Named qualifier
+ assert getInstanceByName("grocery") != null;
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "p")
+ public void testGetAnnotationUsedForGettingInterceptorInformation() {
+ // The extension adds the GroceryInterceptorBinding
+ Grocery grocery = getInstanceByType(Grocery.class, new AnyLiteral());
+ assert grocery.foo().equals("foo");
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "r")
+ public void testPreviouslyNonInjectAnnotatedConstructorIsUsed() {
+ assert getInstanceByType(Grocery.class, new
AnyLiteral()).isConstructorWithParameterUsed();
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "t")
+ //WELD-219
+ public void testPreviouslyNonInjectAnnotatedFieldIsInjected() {
+ assert getInstanceByType(Grocery.class, new AnyLiteral()).isVegetablesInjected();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ @SpecAssertion(section = "11.4", id = "u")
+ //WELD-219
+ public void testExtraQualifierIsAppliedToInjectedField() {
+ assert getInstanceByType(Grocery.class, new AnyLiteral()).getFruit() != null;
+ Set<Annotation> qualifiers = getInstanceByType(Grocery.class, new
AnyLiteral()).getFruit().getMetadata().getQualifiers();
+ assert qualifiers.size() == 1;
+ assert annotationSetMatches(qualifiers, Cheap.class);
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "v")
+ public void testProducesCreatesProducerField() {
+ // The extension adds @Producer to the bread field
+ assert getBeans(Bread.class, new AnyLiteral()).size() == 1;
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "w")
+ public void testInjectCreatesInitializerMethod() {
+ // The extension adds @Inject to the nonInjectAnnotatedInitializer() method
+ assert getInstanceByType(Grocery.class, new AnyLiteral()).isWaterInjected();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ @SpecAssertion(section = "11.4", id = "x")
+ public void testQualifierAddedToInitializerParameter() {
+ // The @Cheap qualifier is added to the method parameter
+ Set<Annotation> qualifiers = getInstanceByType(Grocery.class, new
AnyLiteral()).getInitializerFruit().getMetadata().getQualifiers();
+ assert annotationSetMatches(qualifiers, Cheap.class);
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "y")
+ public void testProducesCreatesProducerMethod() {
+ // The extension adds @Producer to the getMilk() method
+ assert getBeans(Milk.class, new AnyLiteral()).size() == 1;
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "z")
+ public void testQualifierIsAppliedToProducerMethod() {
+ // The extension adds @Expensive to the getMilk() method
+ assert getBeans(Yogurt.class, new ExpensiveLiteral()).size() == 1;
+ assert getBeans(Yogurt.class, new CheapLiteral()).size() == 0;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ @SpecAssertion(section = "11.4", id = "aa")
+ public void testQualifierIsAppliedToProducerMethodParameter() {
+ // The @Cheap qualifier is added to the method parameter
+ Set<Annotation> qualifiers = getInstanceByType(Yogurt.class, new
AnyLiteral()).getFruit().getMetadata().getQualifiers();
+ assert qualifiers.size() == 1;
+ assert annotationSetMatches(qualifiers, Cheap.class);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ @SpecAssertions({
+ @SpecAssertion(section="11.4", id="ae"),
+ @SpecAssertion(section="11.4", id="ag")
+ })
+ public void testObserverMethod() {
+ getCurrentManager().fireEvent(new Milk(true));
+ Milk event = getInstanceByType(Grocery.class, new
AnyLiteral()).getObserverEvent();
+ TropicalFruit parameter = getInstanceByType(Grocery.class, new
AnyLiteral()).getObserverParameter();
+ assert event != null;
+ assert parameter != null;
+ assert parameter.getMetadata().getQualifiers().size() == 1;
+ assert annotationSetMatches(parameter.getMetadata().getQualifiers(), Cheap.class);
+ }
+
+ @Test
+ @SpecAssertion(section = "11.4", id = "af")
+ public void testExtraQualifierAppliedToObservesMethodParameter() {
+ getCurrentManager().fireEvent(new Bread(true));
+ // normally, the event would be observer, however the extension adds the @Expensive
qualifier to the method parameter
+ assert !getInstanceByType(Grocery.class, new AnyLiteral()).isObserver2Used();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedConstructorWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedConstructorWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedConstructorWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,41 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.util.List;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+class AnnotatedConstructorWrapper<X> extends AnnotatedWrapper implements
AnnotatedConstructor<X>
+{
+
+ private AnnotatedConstructor<X> delegate;
+
+ public AnnotatedConstructorWrapper(AnnotatedConstructor<X> delegate, boolean
keepOriginalAnnotations, Annotation... annotations)
+ {
+ super(delegate, keepOriginalAnnotations, annotations);
+ this.delegate = delegate;
+ }
+
+ public Constructor<X> getJavaMember()
+ {
+ return delegate.getJavaMember();
+ }
+
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return delegate.getParameters();
+ }
+
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return delegate.getDeclaringType();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate.isStatic();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedFieldWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedFieldWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedFieldWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,34 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+class AnnotatedFieldWrapper<X> extends AnnotatedWrapper implements
AnnotatedField<X>
+{
+
+ private AnnotatedField<X> delegate;
+
+ public AnnotatedFieldWrapper(AnnotatedField<X> delegate, boolean
keepOriginalAnnotations, Annotation... annotations)
+ {
+ super(delegate, keepOriginalAnnotations, annotations);
+ this.delegate = delegate;
+ }
+
+ public Field getJavaMember()
+ {
+ return delegate.getJavaMember();
+ }
+
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return delegate.getDeclaringType();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate.isStatic();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedMethodWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedMethodWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedMethodWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,52 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+class AnnotatedMethodWrapper<X> extends AnnotatedWrapper implements
AnnotatedMethod<X>
+{
+
+ private AnnotatedMethod<X> delegate;
+
+ public AnnotatedMethodWrapper(AnnotatedMethod<X> delegate, boolean
keepOriginalAnnotations, Annotation... annotations)
+ {
+ super(delegate, keepOriginalAnnotations, annotations);
+ this.delegate = delegate;
+ }
+
+ public Method getJavaMember()
+ {
+ return delegate.getJavaMember();
+ }
+
+ public List<AnnotatedParameter<X>> getParameters()
+ {
+ return delegate.getParameters();
+ }
+
+ public AnnotatedType<X> getDeclaringType()
+ {
+ return delegate.getDeclaringType();
+ }
+
+ public boolean isStatic()
+ {
+ return delegate.isStatic();
+ }
+
+ @Override
+ public Set<Annotation> getAnnotations()
+ {
+ // TODO Auto-generated method stub
+ return super.getAnnotations();
+ }
+
+
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedParameterWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedParameterWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedParameterWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,28 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+
+import javax.enterprise.inject.spi.AnnotatedCallable;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+
+class AnnotatedParameterWrapper<X> extends AnnotatedWrapper implements
AnnotatedParameter<X>
+{
+ private AnnotatedParameter<X> delegate;
+
+ public AnnotatedParameterWrapper(AnnotatedParameter<X> delegate, boolean
keepOriginalAnnotations, Annotation... annotations)
+ {
+ super(delegate, keepOriginalAnnotations, annotations);
+ this.delegate = delegate;
+ }
+
+ public AnnotatedCallable<X> getDeclaringCallable()
+ {
+ return delegate.getDeclaringCallable();
+ }
+
+ public int getPosition()
+ {
+ return delegate.getPosition();
+ }
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedTypeWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedTypeWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedTypeWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,42 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.jsr299.tck.tests.extensions.alternative.metadata.AnnotatedWrapper;
+
+public class AnnotatedTypeWrapper<X> extends AnnotatedWrapper implements
AnnotatedType<X>
+{
+ private AnnotatedType<X> delegate;
+
+ public AnnotatedTypeWrapper(AnnotatedType<X> delegate, boolean
keepOriginalAnnotations, Annotation...annotations)
+ {
+ super(delegate, keepOriginalAnnotations, annotations);
+ this.delegate = delegate;
+ }
+
+ public Set<AnnotatedConstructor<X>> getConstructors()
+ {
+ return delegate.getConstructors();
+ }
+
+ public Set<AnnotatedField<? super X>> getFields()
+ {
+ return delegate.getFields();
+ }
+
+ public Class<X> getJavaClass()
+ {
+ return delegate.getJavaClass();
+ }
+
+ public Set<AnnotatedMethod<? super X>> getMethods()
+ {
+ return delegate.getMethods();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/AnnotatedWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,63 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Annotated;
+
+class AnnotatedWrapper implements Annotated
+{
+
+ private Annotated delegate;
+ private Set<Annotation> annotations;
+
+ public AnnotatedWrapper(Annotated delegate, boolean keepOriginalAnnotations,
Annotation... annotations)
+ {
+ this.delegate = delegate;
+ this.annotations = new HashSet<Annotation>(Arrays.asList(annotations));
+ if (keepOriginalAnnotations)
+ {
+ this.annotations.addAll(delegate.getAnnotations());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public <T extends Annotation> T getAnnotation(Class<T> arg0)
+ {
+ for (Annotation annotation : annotations) {
+ if (arg0.isAssignableFrom(annotation.annotationType())) {
+ return (T) annotation;
+ }
+ }
+ return null;
+ }
+
+ public Set<Annotation> getAnnotations()
+ {
+ return Collections.unmodifiableSet(annotations);
+ }
+
+ public Type getBaseType()
+ {
+ return delegate.getBaseType();
+ }
+
+ public Set<Type> getTypeClosure()
+ {
+ return delegate.getTypeClosure();
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> arg0)
+ {
+ for (Annotation annotation : annotations) {
+ if (arg0.isAssignableFrom(annotation.annotationType())) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Bread.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Bread.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Bread.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,11 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+class Bread
+{
+ @SuppressWarnings("unused")
+ private boolean fresh;
+
+ public Bread(boolean fresh) {
+ this.fresh = fresh;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Cheap.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Cheap.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Cheap.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+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.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+@interface Cheap
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/CheapLiteral.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/CheapLiteral.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/CheapLiteral.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+class CheapLiteral extends AnnotationLiteral<Cheap> implements Cheap
+{
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Expensive.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Expensive.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Expensive.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,22 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+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.inject.Qualifier;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@Qualifier
+@interface Expensive
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ExpensiveLiteral.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ExpensiveLiteral.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ExpensiveLiteral.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import javax.enterprise.inject.AnnotationLiteral;
+
+class ExpensiveLiteral extends AnnotationLiteral<Expensive> implements Expensive
+{
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Fruit.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Fruit.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Fruit.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+
+interface Fruit
+{
+ InjectionPoint getMetadata();
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Grocery.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Grocery.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Grocery.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,109 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+@SuppressWarnings( "unused" )
+@ApplicationScoped
+@Expensive
+class Grocery implements Shop
+{
+ private Vegetables vegetables;
+ @Inject
+ private Fruit fruit;
+ private boolean constructorWithParameterUsed = false;
+ private TropicalFruit initializerFruit = null;
+ private Bread bread = new Bread(true);
+ private Water water = null;
+
+ private Milk observerEvent = null;
+ private TropicalFruit observerParameter = null;
+ private boolean observer2Used = false;
+
+ public Grocery()
+ {
+ }
+
+ public Grocery(@Any TropicalFruit fruit) {
+ constructorWithParameterUsed = true;
+ }
+
+ public void nonInjectAnnotatedInitializer(@Any Water water) {
+ this.water = water;
+ }
+
+ @Inject
+ public void initializer(@Any TropicalFruit fruit) {
+ this.initializerFruit = fruit;
+ }
+
+ public String foo()
+ {
+ return "bar";
+ }
+
+ public boolean isVegetablesInjected()
+ {
+ return vegetables != null;
+ }
+
+ public Fruit getFruit()
+ {
+ return fruit;
+ }
+
+ public boolean isConstructorWithParameterUsed()
+ {
+ return constructorWithParameterUsed;
+ }
+
+ public TropicalFruit getInitializerFruit()
+ {
+ return initializerFruit;
+ }
+
+ public Milk getMilk()
+ {
+ return new Milk(true);
+ }
+
+ @Produces @Cheap
+ public Yogurt getYogurt(@Any TropicalFruit fruit)
+ {
+ return new Yogurt(fruit);
+ }
+
+ public void observer1(Milk event, TropicalFruit fruit) {
+ observerEvent = event;
+ observerParameter = fruit;
+ }
+
+ public void observer2(@Observes Bread event) {
+ observer2Used = true;
+ }
+
+ public boolean isWaterInjected() {
+ return water != null;
+ }
+
+ public Milk getObserverEvent()
+ {
+ return observerEvent;
+ }
+
+ public TropicalFruit getObserverParameter()
+ {
+ return observerParameter;
+ }
+
+ public boolean isObserver2Used()
+ {
+ return observer2Used;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptor.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptor.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,23 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.io.Serializable;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@SuppressWarnings("serial")
+@Interceptor
+@GroceryInterceptorBinding
+class GroceryInterceptor implements Serializable
+{
+ @AroundInvoke
+ public Object interceptFoo(InvocationContext ctx) throws Exception
+ {
+ if (ctx.getMethod().getName().equals("foo"))
+ {
+ return "foo";
+ }
+ return ctx.proceed();
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptorBinding.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptorBinding.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryInterceptorBinding.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,17 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import javax.interceptor.InterceptorBinding;
+
+@InterceptorBinding
+@Target({TYPE, METHOD})
+@Retention(RUNTIME)
+@interface GroceryInterceptorBinding
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryWrapper.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryWrapper.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/GroceryWrapper.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,232 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Notify;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.TransactionPhase;
+import javax.enterprise.inject.AnnotationLiteral;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.AnnotatedType;
+
+import org.jboss.jsr299.tck.literals.InjectLiteral;
+
+public class GroceryWrapper extends AnnotatedTypeWrapper<Grocery>
+{
+ private final Set<Type> typeClosure = new HashSet<Type>();
+ private static boolean getBaseTypeOfFruitFieldUsed = false;
+ private static boolean getTypeClosureUsed = false;
+
+ public GroceryWrapper(AnnotatedType<Grocery> delegate)
+ {
+ super(delegate, false, new AnnotationLiteral<RequestScoped>()
+ {
+ }, new CheapLiteral(), new AnnotationLiteral<NamedStereotype>()
+ {
+ }, new AnnotationLiteral<GroceryInterceptorBinding>(){});
+ typeClosure.add(Grocery.class);
+ typeClosure.add(Object.class);
+ }
+
+ @Override
+ public Set<Type> getTypeClosure()
+ {
+ getTypeClosureUsed = true;
+ return typeClosure;
+ }
+
+ @Override
+ public Set<AnnotatedConstructor<Grocery>> getConstructors()
+ {
+ Set<AnnotatedConstructor<Grocery>> constructors = new
HashSet<AnnotatedConstructor<Grocery>>();
+ for (AnnotatedConstructor<Grocery> constructor : super.getConstructors())
+ {
+ if (constructor.getParameters().size() == 1)
+ {
+ constructors.add(wrapConstructor(constructor, new InjectLiteral()));
+ }
+ else
+ {
+ constructors.add(constructor);
+ }
+ }
+ return constructors;
+ }
+
+ @Override
+ public Set<AnnotatedField<? super Grocery>> getFields()
+ {
+ Set<AnnotatedField<? super Grocery>> fields = new
HashSet<AnnotatedField<? super Grocery>>();
+ for (AnnotatedField<? super Grocery> field : super.getFields())
+ {
+ if (field.getBaseType().equals(Vegetables.class))
+ {
+ fields.add(wrapField(field, new InjectLiteral()));
+ }
+ else
+ if (field.getJavaMember().getName().equals("fruit"))
+ {
+ fields.add(wrapFruitField(field, new CheapLiteral()));
+ }
+ else if (field.getBaseType().equals(Bread.class))
+ {
+ fields.add(wrapField(field, new AnnotationLiteral<Produces>()
+ {
+ }));
+ }
+ else
+ {
+ fields.add(field);
+ }
+ }
+ return fields;
+ }
+
+ @Override
+ public Set<AnnotatedMethod<? super Grocery>> getMethods()
+ {
+ Set<AnnotatedMethod<? super Grocery>> methods = new
HashSet<AnnotatedMethod<? super Grocery>>();
+ for (AnnotatedMethod<? super Grocery> method : super.getMethods())
+ {
+ if (method.getJavaMember().getName().equals("getMilk"))
+ {
+ methods.add(wrapMethod(method, false, new
AnnotationLiteral<Produces>()
+ {
+ }));
+ }
+ else if (method.getJavaMember().getName().equals("getYogurt"))
+ {
+ // wrap the method and its parameters
+ AnnotatedMethod<? super Grocery> wrappedMethod = wrapMethod(method,
false, new ExpensiveLiteral(), new AnnotationLiteral<Produces>()
+ {
+ });
+ methods.add(wrapMethodParameters(wrappedMethod, false, new Annotation[] {new
CheapLiteral()}));
+ }
+ else if
(method.getJavaMember().getName().equals("nonInjectAnnotatedInitializer"))
+ {
+ methods.add(wrapMethod(method, false, new InjectLiteral()));
+ }
+ else if (method.getJavaMember().getName().equals("initializer"))
+ {
+ methods.add(wrapMethodParameters(method, false, new Annotation[] { new
CheapLiteral() }));
+ }
+ else if (method.getJavaMember().getName().equals("observer1"))
+ {
+ Annotation[] firstParameterAnnotations = new Annotation[] { new Observes()
+ {
+
+ public TransactionPhase during()
+ {
+ return TransactionPhase.IN_PROGRESS;
+ }
+
+ public Notify notifyObserver()
+ {
+ return Notify.ALWAYS;
+ }
+
+ public Class<? extends Annotation> annotationType()
+ {
+ return Observes.class;
+ }
+
+ } };
+ Annotation[] secondParameterAnnotations = new Annotation[] { new
CheapLiteral() };
+ methods.add(wrapMethodParameters(method, false, firstParameterAnnotations,
secondParameterAnnotations));
+ }
+ else if (method.getJavaMember().getName().equals("observer2"))
+ {
+ methods.add(wrapMethodParameters(method, true, new Annotation[] { new
ExpensiveLiteral() }));
+ }
+ else
+ {
+ methods.add(method);
+ }
+ }
+ return methods;
+ }
+
+ private <Y> AnnotatedConstructor<Y>
wrapConstructor(AnnotatedConstructor<Y> delegate, Annotation... annotations)
+ {
+ return new AnnotatedConstructorWrapper<Y>(delegate, false, annotations);
+ }
+
+ private <Y> AnnotatedField<Y> wrapField(AnnotatedField<Y> delegate,
Annotation... annotations)
+ {
+ return new AnnotatedFieldWrapper<Y>(delegate, false, annotations);
+ }
+
+ private <Y> AnnotatedField<Y> wrapFruitField(AnnotatedField<Y>
delegate, Annotation... annotations)
+ {
+ return new AnnotatedFieldWrapper<Y>(delegate, true, annotations)
+ {
+ @Override
+ public Type getBaseType()
+ {
+ getBaseTypeOfFruitFieldUsed = true;
+ return TropicalFruit.class;
+ }
+
+ @SuppressWarnings("serial")
+ @Override
+ public Set<Type> getTypeClosure()
+ {
+ return new HashSet<Type>() {
+ {
+ add(Object.class);
+ add(Fruit.class);
+ add(TropicalFruit.class);
+ }
+ };
+ }
+
+
+ };
+ }
+
+ private <Y> AnnotatedMethodWrapper<Y> wrapMethod(AnnotatedMethod<Y>
delegate, boolean keepOriginalAnnotations, Annotation... annotations)
+ {
+ return new AnnotatedMethodWrapper<Y>(delegate, keepOriginalAnnotations,
annotations);
+ }
+
+ /**
+ * This method allows you to add a set of Annotations to every method
+ * parameter. Note that the method will remove all method-level annotations.
+ */
+ private <Y> AnnotatedMethodWrapper<Y>
wrapMethodParameters(AnnotatedMethod<Y> delegate, final boolean
keepOriginalAnnotations, final Annotation[]... annotations)
+ {
+ return new AnnotatedMethodWrapper<Y>(delegate, true)
+ {
+ @Override
+ public List<AnnotatedParameter<Y>> getParameters()
+ {
+ List<AnnotatedParameter<Y>> parameters = new
ArrayList<AnnotatedParameter<Y>>();
+ for (AnnotatedParameter<Y> parameter : super.getParameters())
+ {
+ parameters.add(new AnnotatedParameterWrapper<Y>(parameter,
keepOriginalAnnotations, annotations[parameter.getPosition()]));
+ }
+ return parameters;
+ }
+ };
+ }
+
+ public static boolean isGetBaseTypeOfFruitFieldUsed()
+ {
+ return getBaseTypeOfFruitFieldUsed;
+ }
+
+ public static boolean isGetTypeClosureUsed()
+ {
+ return getTypeClosureUsed;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Milk.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Milk.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Milk.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+class Milk
+{
+ @SuppressWarnings("unused")
+ private boolean fresh;
+
+ public Milk(boolean fresh)
+ {
+ this.fresh = fresh;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/NamedStereotype.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/NamedStereotype.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/NamedStereotype.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,19 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.stereotype.Stereotype;
+import javax.inject.Named;
+
+@Target(TYPE)
+@Retention(RUNTIME)
+@Stereotype
+@Named
+@interface NamedStereotype
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ProcessAnnotatedTypeObserver.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ProcessAnnotatedTypeObserver.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/ProcessAnnotatedTypeObserver.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,13 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+
+public class ProcessAnnotatedTypeObserver implements Extension
+{
+
+ public void observeGroceryAnnotatedType(@Observes ProcessAnnotatedType<Grocery>
event) {
+ event.setAnnotatedType(new GroceryWrapper(event.getAnnotatedType()));
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Shop.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Shop.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Shop.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+interface Shop
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/TropicalFruit.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/TropicalFruit.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/TropicalFruit.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,16 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Inject;
+
+@Cheap
+class TropicalFruit implements Fruit
+{
+ @Inject
+ private InjectionPoint metadata;
+
+ public InjectionPoint getMetadata()
+ {
+ return metadata;
+ }
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Vegetables.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Vegetables.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Vegetables.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+import java.io.Serializable;
+
+class Vegetables implements Serializable
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Water.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Water.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Water.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,7 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+@Cheap
+class Water
+{
+
+}
Added:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Yogurt.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Yogurt.java
(rev 0)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/alternative/metadata/Yogurt.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -0,0 +1,15 @@
+package org.jboss.jsr299.tck.tests.extensions.alternative.metadata;
+
+class Yogurt
+{
+ private TropicalFruit fruit;
+
+ public Yogurt(TropicalFruit fruit) {
+ this.fruit = fruit;
+ }
+
+ public TropicalFruit getFruit()
+ {
+ return fruit;
+ }
+}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Bread.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Bread.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Bread.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,11 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-class Bread
-{
- @SuppressWarnings("unused")
- private boolean fresh;
-
- public Bread(boolean fresh) {
- this.fresh = fresh;
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Cheap.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Cheap.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Cheap.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,22 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-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.inject.Qualifier;
-
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
-@Retention(RUNTIME)
-@Documented
-@Qualifier
-@interface Cheap
-{
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/CheapLiteral.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/CheapLiteral.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/CheapLiteral.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,7 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import javax.enterprise.inject.AnnotationLiteral;
-
-class CheapLiteral extends AnnotationLiteral<Cheap> implements Cheap
-{
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Expensive.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Expensive.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Expensive.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,22 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-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.inject.Qualifier;
-
-@Target( { TYPE, METHOD, PARAMETER, FIELD })
-@Retention(RUNTIME)
-@Documented
-@Qualifier
-@interface Expensive
-{
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ExpensiveLiteral.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ExpensiveLiteral.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ExpensiveLiteral.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,7 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import javax.enterprise.inject.AnnotationLiteral;
-
-class ExpensiveLiteral extends AnnotationLiteral<Expensive> implements Expensive
-{
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Fruit.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Fruit.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Fruit.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,8 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-
-interface Fruit
-{
- InjectionPoint getMetadata();
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Grocery.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Grocery.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Grocery.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,79 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.io.Serializable;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.context.SessionScoped;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Produces;
-import javax.inject.Inject;
-
-@SuppressWarnings( "unused" )
-@ApplicationScoped
-@Expensive
-class Grocery implements Shop
-{
- private Vegetables vegetables = null;
- private Fruit fruit;
- private boolean constructorWithParameterUsed = false;
- private TropicalFruit initializerFruit = null;
- private Bread bread = new Bread(true);
- private Water water = null;
-
- public Grocery()
- {
- }
-
- public Grocery(@Any TropicalFruit fruit) {
- constructorWithParameterUsed = true;
- }
-
- public void nonInjectAnnotatedInitializer(@Any Water water) {
- this.water = water;
- }
-
- @Inject
- public void initializer(@Any TropicalFruit fruit) {
- this.initializerFruit = fruit;
- }
-
- public String foo()
- {
- return "bar";
- }
-
- public boolean isVegetablesInjected()
- {
- return vegetables != null;
- }
-
- public Fruit getFruit()
- {
- return fruit;
- }
-
- public boolean isConstructorWithParameterUsed()
- {
- return constructorWithParameterUsed;
- }
-
- public TropicalFruit getInitializerFruit()
- {
- return initializerFruit;
- }
-
- public Milk getMilk()
- {
- return new Milk(true);
- }
-
- @Produces @Cheap
- public Yogurt getYogurt(@Any TropicalFruit fruit)
- {
- return new Yogurt(fruit);
- }
-
- public boolean isWaterInjected() {
- return water != null;
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryAnnotatedType.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryAnnotatedType.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryAnnotatedType.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,181 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.AnnotationLiteral;
-import javax.enterprise.inject.Produces;
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-import org.jboss.jsr299.tck.literals.InjectLiteral;
-
-public class GroceryAnnotatedType<X> extends TestAnnotatedType<X>
-{
- private final Set<Type> typeClosure = new HashSet<Type>();
- private static boolean getBaseTypeOfFruitFieldUsed = false;
- private static boolean getTypeClosureUsed = false;
-
- public GroceryAnnotatedType(AnnotatedType<X> delegate)
- {
- super(delegate, new AnnotationLiteral<RequestScoped>()
- {
- }, new CheapLiteral(), new AnnotationLiteral<NamedStereotype>()
- {
- }, new AnnotationLiteral<GroceryInterceptorBinding>()
- {
- });
- typeClosure.add(Grocery.class);
- typeClosure.add(Object.class);
- }
-
- @Override
- public Set<Type> getTypeClosure()
- {
- getTypeClosureUsed = true;
- return typeClosure;
- }
-
- @Override
- public Set<AnnotatedConstructor<X>> getConstructors()
- {
- Set<AnnotatedConstructor<X>> constructors = new
HashSet<AnnotatedConstructor<X>>();
- for (AnnotatedConstructor<X> constructor : super.getConstructors())
- {
- if (constructor.getParameters().size() == 1)
- {
- constructors.add(wrapConstructor(constructor, new InjectLiteral()));
- }
- else
- {
- constructors.add(constructor);
- }
- }
- return constructors;
- }
-
- @Override
- public Set<AnnotatedField<? super X>> getFields()
- {
- Set<AnnotatedField<? super X>> fields = new
HashSet<AnnotatedField<? super X>>();
- for (AnnotatedField<? super X> field : super.getFields())
- {
- if (field.getBaseType().equals(Vegetables.class))
- {
- fields.add(wrapField(field, new InjectLiteral()));
- }
- else if (field.getJavaMember().getName().equals("fruit"))
- {
- fields.add(wrapFruitField(field, new CheapLiteral(), new InjectLiteral()));
- }
- else if (field.getBaseType().equals(Bread.class))
- {
- fields.add(wrapField(field, new AnnotationLiteral<Produces>()
- {
- }));
- }
- else
- {
- fields.add(field);
- }
- }
- return fields;
- }
-
- @Override
- public Set<AnnotatedMethod<? super X>> getMethods()
- {
- Set<AnnotatedMethod<? super X>> methods = new
HashSet<AnnotatedMethod<? super X>>();
- for (AnnotatedMethod<? super X> method : super.getMethods())
- {
- if (method.getJavaMember().getName().equals("getMilk"))
- {
- methods.add(wrapMethod(method, new AnnotationLiteral<Produces>()
- {
- }));
- }
- else if (method.getJavaMember().getName().equals("getYogurt"))
- {
- methods.add(wrapMethodAndAnnotateEveryParameterWithCheap(method, new
ExpensiveLiteral(), new AnnotationLiteral<Produces>()
- {
- }));
- }
- else if
(method.getJavaMember().getName().equals("nonInjectAnnotatedInitializer"))
- {
- methods.add(wrapMethod(method, new InjectLiteral()));
- }
- else if (method.getJavaMember().getName().equals("initializer"))
- {
- methods.add(wrapMethodAndAnnotateEveryParameterWithCheap(method, new
InjectLiteral()));
- }
- else
- {
- methods.add(method);
- }
- }
- return methods;
- }
-
- private <Y> AnnotatedConstructor<Y>
wrapConstructor(AnnotatedConstructor<Y> delegate, Annotation... annotations)
- {
- return new TestAnnotatedConstructor<Y>(delegate, annotations);
- }
-
- private <Y> AnnotatedField<Y> wrapField(AnnotatedField<Y> delegate,
Annotation... annotations)
- {
- return new TestAnnotatedField<Y>(delegate, annotations);
- }
-
- private <Y> AnnotatedField<Y> wrapFruitField(AnnotatedField<Y>
delegate, Annotation... annotations)
- {
- return new TestAnnotatedField<Y>(delegate, annotations){
- @Override
- public Type getBaseType()
- {
- getBaseTypeOfFruitFieldUsed = true;
- return TropicalFruit.class;
- }
- };
- }
-
- private <Y> TestAnnotatedMethod<Y> wrapMethod(AnnotatedMethod<Y>
delegate, Annotation... annotations)
- {
- return new TestAnnotatedMethod<Y>(delegate, annotations);
- }
-
- private <Y> TestAnnotatedMethod<Y>
wrapMethodAndAnnotateEveryParameterWithCheap(AnnotatedMethod<Y> delegate,
Annotation... annotations)
- {
- return new TestAnnotatedMethod<Y>(delegate, annotations)
- {
- @Override
- public List<AnnotatedParameter<Y>> getParameters()
- {
- List<AnnotatedParameter<Y>> parameters = new
ArrayList<AnnotatedParameter<Y>>();
- for (AnnotatedParameter<Y> parameter : super.getParameters())
- {
- parameters.add(new TestAnnotatedParameter<Y>(parameter, new
CheapLiteral()));
- }
- return parameters;
- }
-
- };
- }
-
- public static boolean isGetBaseTypeOfFruitFieldUsed()
- {
- return getBaseTypeOfFruitFieldUsed;
- }
-
- public static boolean isGetTypeClosureUsed()
- {
- return getTypeClosureUsed;
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptor.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptor.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,23 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.Interceptor;
-import javax.interceptor.InvocationContext;
-
-@Interceptor
-@GroceryInterceptorBinding
-class GroceryInterceptor
-{
- @AroundInvoke
- public Object interceptFoo(InvocationContext ctx) throws Exception
- {
- if (ctx.getMethod().getName().equals("foo"))
- {
- return "foo";
- }
- else
- {
- return ctx.proceed();
- }
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptorBinding.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptorBinding.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/GroceryInterceptorBinding.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,17 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import javax.interceptor.InterceptorBinding;
-
-@InterceptorBinding
-@Target({TYPE, METHOD})
-@Retention(RUNTIME)
-@interface GroceryInterceptorBinding
-{
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Milk.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Milk.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Milk.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,12 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-class Milk
-{
- @SuppressWarnings("unused")
- private boolean fresh;
-
- public Milk(boolean fresh)
- {
- this.fresh = fresh;
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/NamedStereotype.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/NamedStereotype.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/NamedStereotype.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,19 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import static java.lang.annotation.ElementType.TYPE;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.enterprise.inject.stereotype.Stereotype;
-import javax.inject.Named;
-
-@Target(TYPE)
-@Retention(RUNTIME)
-@Stereotype
-@Named
-@interface NamedStereotype
-{
-
-}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeObserver.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeObserver.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeObserver.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -38,10 +38,6 @@
{
wrapAnnotatedType(event);
}
- else if (event.getAnnotatedType().getJavaClass().equals(Grocery.class))
- {
- wrapGroceryAnnotatedType(event);
- }
}
private <X> void wrapAnnotatedType(ProcessAnnotatedType<X> event)
@@ -49,11 +45,6 @@
event.setAnnotatedType(new TestAnnotatedType<X>(event.getAnnotatedType()));
}
- private <X> void wrapGroceryAnnotatedType(ProcessAnnotatedType<X> event)
- {
- event.setAnnotatedType(new
GroceryAnnotatedType<X>(event.getAnnotatedType()));
- }
-
public static HashSet<Class<?>> getAnnotatedclasses()
{
return annotatedClasses;
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeTest.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeTest.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/ProcessAnnotatedTypeTest.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -17,13 +17,7 @@
package org.jboss.jsr299.tck.tests.extensions.annotated;
-import java.lang.annotation.Annotation;
-import java.util.Set;
-
-import javax.enterprise.context.RequestScoped;
-
import org.jboss.jsr299.tck.AbstractJSR299Test;
-import org.jboss.jsr299.tck.literals.AnyLiteral;
import org.jboss.test.audit.annotations.SpecAssertion;
import org.jboss.test.audit.annotations.SpecAssertions;
import org.jboss.test.audit.annotations.SpecVersion;
@@ -31,7 +25,6 @@
import org.jboss.testharness.impl.packaging.IntegrationTest;
import org.jboss.testharness.impl.packaging.Resource;
import org.jboss.testharness.impl.packaging.Resources;
-import org.jboss.testharness.impl.packaging.jsr299.BeansXml;
import org.testng.annotations.Test;
@@ -43,7 +36,6 @@
*
*/
@Artifact
-(a)BeansXml("beans.xml")
@Resources({
@Resource(source="javax.enterprise.inject.spi.Extension",
destination="WEB-INF/classes/META-INF/services/javax.enterprise.inject.spi.Extension")
})
@@ -93,118 +85,4 @@
{
assert getCurrentManager().getBeans(VetoedBean.class).isEmpty();
}
-
- @Test(groups = "ri-broken")
- @SpecAssertion(section = "11.4", id = "h")
- // WELD-200
- public void testGetBaseTypeUsedToDetermineTypeOfInjectionPoing() {
- // The base type of the fruit injection point is overridden to TropicalFruit
- assert GroceryAnnotatedType.isGetBaseTypeOfFruitFieldUsed();
- assert getInstanceByType(Grocery.class, new
AnyLiteral()).getFruit().getMetadata().getType().equals(TropicalFruit.class);
- }
-
- @Test(groups = "ri-broken")
- @SpecAssertion(section = "11.4", id = "k")
- // WELD-201
- public void testGetTypeClosureUsed() {
- assert GroceryAnnotatedType.isGetTypeClosureUsed();
- // should be [Object, Grocery] instead of [Object, Shop, Grocery]
- assert getBeans(Grocery.class, new
AnyLiteral()).iterator().next().getTypes().size() == 2;
- assert getBeans(Shop.class, new AnyLiteral()).size() == 0;
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "l")
- public void testGetAnnotationUsedForGettingScopeInformation() {
- // @ApplicationScoped is overridden by @RequestScoped
- assert getBeans(Grocery.class, new
AnyLiteral()).iterator().next().getScope().isAssignableFrom(RequestScoped.class);
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "m")
- public void testGetAnnotationUsedForGettingQualifierInformation() {
- // @Expensive is overridden by @Cheap
- assert getBeans(Grocery.class, new CheapLiteral()).size() == 1;
- assert getBeans(Grocery.class, new ExpensiveLiteral()).size() == 0;
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "n")
- public void testGetAnnotationUsedForGettingStereotypeInformation() {
- // The extension adds a stereotype with @Named qualifier
- assert getInstanceByName("grocery") != null;
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "p")
- public void testGetAnnotationUsedForGettingInterceptorInformation() {
- // The extension adds the GroceryInterceptorBinding
- assert getInstanceByType(Grocery.class, new
AnyLiteral()).foo().equals("foo");
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "r")
- public void testPreviouslyNonInjectAnnotatedConstructorIsUsed() {
- assert getInstanceByType(Grocery.class, new
AnyLiteral()).isConstructorWithParameterUsed();
- }
-
- @Test(groups="ri-broken")
- @SpecAssertion(section = "11.4", id = "t")
- public void testPreviouslyNonInjectAnnotatedFieldIsInjected() {
- assert getInstanceByType(Grocery.class, new AnyLiteral()).isVegetablesInjected();
- }
-
- @Test(groups="ri-broken")
- @SpecAssertion(section = "11.4", id = "u")
- public void testExtraQualifierIsAppliedToInjectedField() {
- Set<Annotation> qualifiers = getInstanceByType(Grocery.class, new
AnyLiteral()).getFruit().getMetadata().getQualifiers();
- assert qualifiers.size() == 1;
- assert annotationSetMatches(qualifiers, Cheap.class);
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "v")
- public void testProducesCreatesProducerField() {
- // The extension adds @Producer to the bread field
- assert getBeans(Bread.class, new AnyLiteral()).size() == 1;
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "w")
- public void testInjectCreatesInitializerMethod() {
- // The extension adds @Inject to the nonInjectAnnotatedInitializer() method
- assert getInstanceByType(Grocery.class, new AnyLiteral()).isWaterInjected();
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "x")
- public void testQualifierAddedToInitializerParameter() {
- // The @Cheap qualifier is added to the method parameter
- Set<Annotation> qualifiers = getInstanceByType(Grocery.class, new
AnyLiteral()).getInitializerFruit().getMetadata().getQualifiers();
- assert annotationSetMatches(qualifiers, Cheap.class);
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "y")
- public void testProducesCreatesProducerMethod() {
- // The extension adds @Producer to the getMilk() method
- assert getBeans(Milk.class, new AnyLiteral()).size() == 1;
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "z")
- public void testQualifierIsAppliedToProducerMethod() {
- // The extension adds @Expensive to the getMilk() method
- assert getBeans(Yogurt.class, new ExpensiveLiteral()).size() == 1;
- assert getBeans(Yogurt.class, new CheapLiteral()).size() == 0;
- }
-
- @Test
- @SpecAssertion(section = "11.4", id = "aa")
- public void testQualifierIsAppliedToProducerMethodParameter() {
- // The @Cheap qualifier is added to the method parameter
- Set<Annotation> qualifiers = getInstanceByType(Yogurt.class, new
AnyLiteral()).getFruit().getMetadata().getQualifiers();
- assert qualifiers.size() == 1;
- assert annotationSetMatches(qualifiers, Cheap.class);
- }
}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Shop.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Shop.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Shop.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-interface Shop
-{
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedConstructor.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedConstructor.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedConstructor.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,41 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.util.List;
-
-import javax.enterprise.inject.spi.AnnotatedConstructor;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-class TestAnnotatedConstructor<X> extends TestAnnotated implements
AnnotatedConstructor<X>
-{
-
- private AnnotatedConstructor<X> delegate;
-
- public TestAnnotatedConstructor(AnnotatedConstructor<X> delegate, Annotation...
annotations)
- {
- super(delegate, annotations);
- this.delegate = delegate;
- }
-
- public Constructor<X> getJavaMember()
- {
- return delegate.getJavaMember();
- }
-
- public List<AnnotatedParameter<X>> getParameters()
- {
- return delegate.getParameters();
- }
-
- public AnnotatedType<X> getDeclaringType()
- {
- return delegate.getDeclaringType();
- }
-
- public boolean isStatic()
- {
- return delegate.isStatic();
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedField.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedField.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedField.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,34 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-
-import javax.enterprise.inject.spi.AnnotatedField;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-class TestAnnotatedField<X> extends TestAnnotated implements
AnnotatedField<X>
-{
-
- private AnnotatedField<X> delegate;
-
- public TestAnnotatedField(AnnotatedField<X> delegate, Annotation...
annotations)
- {
- super(delegate, annotations);
- this.delegate = delegate;
- }
-
- public Field getJavaMember()
- {
- return delegate.getJavaMember();
- }
-
- public AnnotatedType<X> getDeclaringType()
- {
- return delegate.getDeclaringType();
- }
-
- public boolean isStatic()
- {
- return delegate.isStatic();
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedMethod.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedMethod.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedMethod.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,52 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.List;
-import java.util.Set;
-
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.AnnotatedType;
-
-class TestAnnotatedMethod<X> extends TestAnnotated implements
AnnotatedMethod<X>
-{
-
- private AnnotatedMethod<X> delegate;
-
- public TestAnnotatedMethod(AnnotatedMethod<X> delegate, Annotation...
annotations)
- {
- super(delegate, annotations);
- this.delegate = delegate;
- }
-
- public Method getJavaMember()
- {
- return delegate.getJavaMember();
- }
-
- public List<AnnotatedParameter<X>> getParameters()
- {
- return delegate.getParameters();
- }
-
- public AnnotatedType<X> getDeclaringType()
- {
- return delegate.getDeclaringType();
- }
-
- public boolean isStatic()
- {
- return delegate.isStatic();
- }
-
- @Override
- public Set<Annotation> getAnnotations()
- {
- // TODO Auto-generated method stub
- return super.getAnnotations();
- }
-
-
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedParameter.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedParameter.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedParameter.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,28 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import java.lang.annotation.Annotation;
-
-import javax.enterprise.inject.spi.AnnotatedCallable;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-
-class TestAnnotatedParameter<X> extends TestAnnotated implements
AnnotatedParameter<X>
-{
- private AnnotatedParameter<X> delegate;
-
- public TestAnnotatedParameter(AnnotatedParameter<X> delegate, Annotation...
annotations)
- {
- super(delegate, annotations);
- this.delegate = delegate;
- }
-
- public AnnotatedCallable<X> getDeclaringCallable()
- {
- return delegate.getDeclaringCallable();
- }
-
- public int getPosition()
- {
- return delegate.getPosition();
- }
-
-}
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedType.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedType.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TestAnnotatedType.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -58,5 +58,4 @@
{
return getMethodsUsed;
}
-
}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TropicalFruit.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TropicalFruit.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/TropicalFruit.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,16 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.inject.Inject;
-
-@Cheap
-class TropicalFruit implements Fruit
-{
- @Inject
- private InjectionPoint metadata;
-
- public InjectionPoint getMetadata()
- {
- return metadata;
- }
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Vegetables.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Vegetables.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Vegetables.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,6 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-class Vegetables
-{
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Water.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Water.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Water.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,7 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-@Cheap
-class Water
-{
-
-}
Deleted:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Yogurt.java
===================================================================
---
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Yogurt.java 2009-10-21
14:36:55 UTC (rev 4210)
+++
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/extensions/annotated/Yogurt.java 2009-10-21
14:59:56 UTC (rev 4211)
@@ -1,15 +0,0 @@
-package org.jboss.jsr299.tck.tests.extensions.annotated;
-
-class Yogurt
-{
- private TropicalFruit fruit;
-
- public Yogurt(TropicalFruit fruit) {
- this.fruit = fruit;
- }
-
- public TropicalFruit getFruit()
- {
- return fruit;
- }
-}