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/03/18 19:47:17 UTC

svn commit: r1579011 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/portable/ test/java/org/apache/webbeans/test/events/injectiontarget/ test/java/org/apache/webbeans/test/unittests/portable/events/

Author: struberg
Date: Tue Mar 18 18:47:17 2014
New Revision: 1579011

URL: http://svn.apache.org/r1579011
Log:
OWB-940 add a unit test for ProcessInjection gets filled correctly

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionTargetTest.java
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java?rev=1579011&r1=1579010&r2=1579011&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/portable/InjectionTargetImpl.java Tue Mar 18 18:47:17 2014
@@ -106,10 +106,10 @@ public class InjectionTargetImpl<T> exte
 
     private List<Interceptor<?>> aroundConstructInterceptors;
 
-    public InjectionTargetImpl(AnnotatedType<T> annotatedType, Set<InjectionPoint> points, WebBeansContext webBeansContext,
+    public InjectionTargetImpl(AnnotatedType<T> annotatedType, Set<InjectionPoint> injectionPoints, WebBeansContext webBeansContext,
                                List<AnnotatedMethod<?>> postConstructMethods, List<AnnotatedMethod<?>> preDestroyMethods)
     {
-        super(points);
+        super(injectionPoints);
         Asserts.assertNotNull(annotatedType);
         Asserts.assertNotNull(webBeansContext);
         this.annotatedType = annotatedType;

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionTargetTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionTargetTest.java?rev=1579011&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionTargetTest.java (added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionTargetTest.java Tue Mar 18 18:47:17 2014
@@ -0,0 +1,76 @@
+package org.apache.webbeans.test.events.injectiontarget;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.inject.Inject;
+
+import junit.framework.Assert;
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+/**
+ * Checks that the InjectionTarget in ProcessInjectionTarget
+ * is correctly filled.
+ */
+public class ProcessInjectionTargetTest extends AbstractUnitTest
+{
+    @Test
+    public void testInjectionTargetIsValid() throws Exception
+    {
+        InjectionTargetExtension injectionTargetExtension = new InjectionTargetExtension();
+        addExtension(injectionTargetExtension);
+        startContainer(SomeBean.class, SomeOtherBean.class);
+
+        Assert.assertNotNull(injectionTargetExtension.getProcessInjectionTarget());
+        InjectionTarget injectionTarget = injectionTargetExtension.getProcessInjectionTarget().getInjectionTarget();
+        Assert.assertNotNull(injectionTarget);
+        Assert.assertNotNull(injectionTarget.getInjectionPoints());
+        Assert.assertEquals(1, injectionTarget.getInjectionPoints().size());
+    }
+
+    public static class InjectionTargetExtension implements Extension
+    {
+        private ProcessInjectionTarget processInjectionTarget;
+
+
+        public void observePit(@Observes ProcessInjectionTarget<SomeBean> pit)
+        {
+            this.processInjectionTarget = pit;
+        }
+
+        public ProcessInjectionTarget getProcessInjectionTarget()
+        {
+            return processInjectionTarget;
+        }
+    }
+
+    @RequestScoped
+    public static class SomeBean
+    {
+        private @Inject SomeOtherBean someOtherBean;
+
+        public SomeOtherBean getSomeOtherBean()
+        {
+            return someOtherBean;
+        }
+    }
+
+    @RequestScoped
+    public static class SomeOtherBean
+    {
+        private int meaningOfLife = 42;
+
+        public int getMeaningOfLife()
+        {
+            return meaningOfLife;
+        }
+
+        public void setMeaningOfLife(int meaningOfLife)
+        {
+            this.meaningOfLife = meaningOfLife;
+        }
+    }
+}

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java?rev=1579011&r1=1579010&r2=1579011&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java (original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java Tue Mar 18 18:47:17 2014
@@ -82,4 +82,5 @@ public class ExtensionTest extends Abstr
 
         Assert.assertNotNull(MyExtension.beforeShutdownEvent);
     }
+
 }