Author: shane.bryzak(a)jboss.com
Date: 2009-03-30 22:43:36 -0400 (Mon, 30 Mar 2009)
New Revision: 2277
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/InjectedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java
Log:
test for 5.7.1.c
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java 2009-03-31
02:43:36 UTC (rev 2277)
@@ -0,0 +1,9 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+import javax.inject.AnnotationLiteral;
+import javax.inject.Current;
+
+public class CurrentBinding extends AnnotationLiteral<Current> implements Current
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java 2009-03-31
02:43:36 UTC (rev 2277)
@@ -0,0 +1,86 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.inject.manager.Bean;
+import javax.inject.manager.InjectionPoint;
+
+import org.hibernate.tck.annotations.SpecAssertion;
+import org.jboss.jsr299.tck.AbstractJSR299Test;
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.testng.annotations.Test;
+
+@Artifact
+public class DependencyResolutionTest extends AbstractJSR299Test
+{
+ class MockInjectionPoint implements InjectionPoint
+ {
+ private Bean<?> bean;
+ private Type type;
+ private Member member;
+ private Set<Annotation> bindings;
+
+ public MockInjectionPoint(Bean<?> bean, Type type, Member member,
+ Set<Annotation> bindings)
+ {
+ this.bean = bean;
+ this.type = type;
+ this.member = member;
+ this.bindings = bindings;
+ }
+
+ public <T extends Annotation> T getAnnotation(Class<T> arg0)
+ {
+ return null;
+ }
+
+ public Annotation[] getAnnotations()
+ {
+ return null;
+ }
+
+ public Bean<?> getBean()
+ {
+ return bean;
+ }
+
+ public Set<Annotation> getBindings()
+ {
+ return bindings;
+ }
+
+ public Member getMember()
+ {
+ return member;
+ }
+
+ public Type getType()
+ {
+ return type;
+ }
+
+ public boolean isAnnotationPresent(Class<? extends Annotation> arg0)
+ {
+ return false;
+ }
+ }
+
+ @Test
+ @SpecAssertion(section = "5.7.1", id = "c")
+ public void testGetInstanceToInjectReturnsContextualInstance() throws Exception
+ {
+ Bean<Vanilla> vanillaBean =
getCurrentManager().resolveByType(Vanilla.class).iterator().next();
+
+ Field injectedField = InjectedBean.class.getField("vanilla");
+ Set<Annotation> bindings = new HashSet<Annotation>();
+ bindings.add(new CurrentBinding());
+ MockInjectionPoint injectionPoint = new MockInjectionPoint(vanillaBean,
Vanilla.class, injectedField, bindings);
+
+ assert getCurrentManager().getInstanceToInject(injectionPoint) instanceof Vanilla;
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/InjectedBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/InjectedBean.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/InjectedBean.java 2009-03-31
02:43:36 UTC (rev 2277)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+import javax.inject.Current;
+
+class InjectedBean
+{
+ @Current public Vanilla vanilla;
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Vanilla.java 2009-03-31
02:43:36 UTC (rev 2277)
@@ -0,0 +1,6 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+class Vanilla
+{
+
+}
Show replies by date