You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by st...@apache.org on 2014/08/16 23:53:40 UTC

svn commit: r1618419 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: component/decorator/clean/ injection/injectionpoint/beans/ tests/ unittests/decorator/

Author: struberg
Date: Sat Aug 16 21:53:40 2014
New Revision: 1618419

URL: http://svn.apache.org/r1618419
Log:
fix InjectionPoint test

Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/injectionpoint/beans/ConstructorInjectionPointOwner.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/tests/InjectionPointInjectionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java?rev=1618419&r1=1618418&r2=1618419&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/decorator/clean/ServiceDecorator.java Sat Aug 16 21:53:40 2014
@@ -20,6 +20,7 @@ package org.apache.webbeans.test.compone
 
 import javax.decorator.Delegate;
 import javax.decorator.Decorator;
+import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 import javax.inject.Named;
 
@@ -30,9 +31,16 @@ import org.apache.webbeans.test.componen
 @Named
 public  class ServiceDecorator implements IService
 {
-    @Inject @Delegate @Binding1 IService delegate;
+    private @Inject @Delegate @Binding1 IService delegate;
 
     public static String delegateAttr = null;
+    public static InjectionPoint ip;
+
+    @Inject
+    public ServiceDecorator(InjectionPoint ip)
+    {
+        ServiceDecorator.ip = ip;
+    }
 
     @Override
     public String service()

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/injectionpoint/beans/ConstructorInjectionPointOwner.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/injectionpoint/beans/ConstructorInjectionPointOwner.java?rev=1618419&r1=1618418&r2=1618419&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/injectionpoint/beans/ConstructorInjectionPointOwner.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/injection/injectionpoint/beans/ConstructorInjectionPointOwner.java Sat Aug 16 21:53:40 2014
@@ -15,11 +15,13 @@
  */
 package org.apache.webbeans.test.injection.injectionpoint.beans;
 
+import javax.enterprise.context.Dependent;
 import javax.enterprise.context.SessionScoped;
 import javax.enterprise.inject.spi.InjectionPoint;
 import javax.inject.Inject;
 import java.io.Serializable;
 
+@Dependent
 public class ConstructorInjectionPointOwner extends AbstractInjectionPointOwner
 {
 

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/tests/InjectionPointInjectionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/tests/InjectionPointInjectionTest.java?rev=1618419&r1=1618418&r2=1618419&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/tests/InjectionPointInjectionTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/tests/InjectionPointInjectionTest.java Sat Aug 16 21:53:40 2014
@@ -25,12 +25,15 @@ import static org.junit.Assert.assertNot
 import java.util.ArrayList;
 import java.util.Collection;
 
+import javax.enterprise.context.Dependent;
 import javax.enterprise.context.spi.CreationalContext;
 import javax.enterprise.inject.Instance;
 import javax.enterprise.inject.spi.AnnotatedField;
 import javax.enterprise.inject.spi.Bean;
 import javax.enterprise.inject.spi.InjectionPoint;
+import javax.inject.Inject;
 
+import junit.framework.Assert;
 import org.apache.webbeans.annotation.DefaultLiteral;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.injection.injectionpoint.beans.AbstractInjectionPointOwner;
@@ -133,5 +136,35 @@ public class InjectionPointInjectionTest
         assertNotNull(pmp.getInjectionPoint());
     }
 
+    @Test
+    public void testManualConstructorInjectionPoint() throws Exception
+    {
+        startContainer(ConstructorInjectionPointOwner.class);
+        ConstructorInjectionPointOwner owner = getInstance(ConstructorInjectionPointOwner.class);
+        Assert.assertNotNull(owner);
+        Assert.assertNull(owner.getInjectionPoint());
+    }
+
+    @Test
+    public void testIndirectConstructorInjectionPoint() throws Exception
+    {
+        startContainer(ConstructorInjectionPointOwner.class, ConstructorInjectionOwner.class);
+        ConstructorInjectionOwner owner = getInstance(ConstructorInjectionOwner.class);
+        Assert.assertNotNull(owner);
+        Assert.assertNotNull(owner.getConstructorInjectionPointOwner());
+        Assert.assertNotNull(owner.getConstructorInjectionPointOwner().getInjectionPoint());
+        Assert.assertNotNull(owner.getConstructorInjectionPointOwner().getName());
+    }
+
+    @Dependent
+    public static class ConstructorInjectionOwner
+    {
+        private @Inject ConstructorInjectionPointOwner constructorInjectionPointOwner;
+
+        public ConstructorInjectionPointOwner getConstructorInjectionPointOwner()
+        {
+            return constructorInjectionPointOwner;
+        }
+    }
 
 }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java?rev=1618419&r1=1618418&r2=1618419&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/decorator/Decorator1Test.java Sat Aug 16 21:53:40 2014
@@ -53,6 +53,7 @@ public class Decorator1Test extends Abst
         startContainer(ServiceDecorator.class, CheckWithCheckPayment.class, ServiceImpl1.class, Binding1.class);
 
         ServiceDecorator.delegateAttr = null;
+        ServiceDecorator.ip = null;
 
         ServiceImpl1 serviceImpl = getInstance(ServiceImpl1.class, new Annotation[]{new Binding1Literal()});
         String s = serviceImpl.service();
@@ -67,6 +68,10 @@ public class Decorator1Test extends Abst
         Assert.assertTrue(decs.size() > 0);
 
         Assert.assertEquals(ServiceDecorator.delegateAttr, "ServiceImpl1");
+
+        // actually the following is NOT defined in the spec!
+        // Assert.assertNotNull(ServiceDecorator.ip);
+        // It is _currently_ totally fine that it is null.
     }
 
     @Test