Author: shane.bryzak(a)jboss.com
Date: 2009-03-30 23:54:17 -0400 (Mon, 30 Mar 2009)
New Revision: 2278
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Other.java
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java
Modified:
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
Log:
5.7.1 tests
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BakedBean_Broken.java 2009-03-31
03:54:17 UTC (rev 2278)
@@ -0,0 +1,12 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+public class BakedBean_Broken
+{
+ /*
+ * private constructor makes this bean unproxyable
+ */
+ private BakedBean_Broken()
+ {
+
+ }
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/BrokenInjectedBean.java 2009-03-31
03:54:17 UTC (rev 2278)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+import javax.inject.Current;
+
+class BrokenInjectedBean
+{
+ @Current public BakedBean_Broken bakedBean;
+}
Modified:
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 2009-03-31
02:43:36 UTC (rev 2277)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/CurrentBinding.java 2009-03-31
03:54:17 UTC (rev 2278)
@@ -3,7 +3,7 @@
import javax.inject.AnnotationLiteral;
import javax.inject.Current;
-public class CurrentBinding extends AnnotationLiteral<Current> implements Current
+class CurrentBinding extends AnnotationLiteral<Current> implements Current
{
}
Modified:
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 2009-03-31
02:43:36 UTC (rev 2277)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/DependencyResolutionTest.java 2009-03-31
03:54:17 UTC (rev 2278)
@@ -7,10 +7,13 @@
import java.util.HashSet;
import java.util.Set;
+import javax.inject.UnproxyableDependencyException;
+import javax.inject.UnsatisfiedDependencyException;
import javax.inject.manager.Bean;
import javax.inject.manager.InjectionPoint;
import org.hibernate.tck.annotations.SpecAssertion;
+import org.hibernate.tck.annotations.SpecAssertions;
import org.jboss.jsr299.tck.AbstractJSR299Test;
import org.jboss.testharness.impl.packaging.Artifact;
import org.testng.annotations.Test;
@@ -71,7 +74,10 @@
}
@Test
- @SpecAssertion(section = "5.7.1", id = "c")
+ @SpecAssertions({
+ @SpecAssertion(section = "5.7.1", id = "c"),
+ @SpecAssertion(section = "5.7.1", id = "d")
+ })
public void testGetInstanceToInjectReturnsContextualInstance() throws Exception
{
Bean<Vanilla> vanillaBean =
getCurrentManager().resolveByType(Vanilla.class).iterator().next();
@@ -83,4 +89,44 @@
assert getCurrentManager().getInstanceToInject(injectionPoint) instanceof Vanilla;
}
+
+ @Test(expectedExceptions = UnsatisfiedDependencyException.class)
+ @SpecAssertion(section = "5.7.1", id = "e")
+ public void testGetInstanceToInjectThrowsUnsatisfiedDependencyException() 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 OtherBinding());
+ MockInjectionPoint injectionPoint = new MockInjectionPoint(vanillaBean,
Vanilla.class, injectedField, bindings);
+
+ assert getCurrentManager().getInstanceToInject(injectionPoint) instanceof Vanilla;
+ }
+
+ @Test(expectedExceptions = UnsatisfiedDependencyException.class)
+ @SpecAssertion(section = "5.7.1", id = "f")
+ public void testGetInstanceToInjectThrowsAmbiguousDependencyException() 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 OtherBinding());
+ MockInjectionPoint injectionPoint = new MockInjectionPoint(vanillaBean,
Vanilla.class, injectedField, bindings);
+ getCurrentManager().getInstanceToInject(injectionPoint);
+ }
+
+ @Test(expectedExceptions = UnproxyableDependencyException.class, groups =
"ri-broken")
+ @SpecAssertion(section = "5.7.1", id = "g")
+ public void testGetInstanceToInjectThrowsUnproxyableDependencyException() throws
Exception
+ {
+ Bean<BakedBean_Broken> bakedBean =
getCurrentManager().resolveByType(BakedBean_Broken.class).iterator().next();
+
+ Field injectedField = BrokenInjectedBean.class.getField("bakedBean");
+ Set<Annotation> bindings = new HashSet<Annotation>();
+ bindings.add(new CurrentBinding());
+ MockInjectionPoint injectionPoint = new MockInjectionPoint(bakedBean,
BakedBean_Broken.class, injectedField, bindings);
+ getCurrentManager().getInstanceToInject(injectionPoint);
+ }
}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Other.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Other.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/Other.java 2009-03-31
03:54:17 UTC (rev 2278)
@@ -0,0 +1,23 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+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.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.BindingType;
+
+@Target( { TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+@BindingType
+public @interface Other
+{
+
+}
Added:
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java
===================================================================
---
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java
(rev 0)
+++
tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/lookup/dependency/resolution/OtherBinding.java 2009-03-31
03:54:17 UTC (rev 2278)
@@ -0,0 +1,8 @@
+package org.jboss.jsr299.tck.tests.lookup.dependency.resolution;
+
+import javax.inject.AnnotationLiteral;
+
+class OtherBinding extends AnnotationLiteral<Other> implements Other
+{
+
+}
Show replies by date