openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1723685 - in /openwebbeans/trunk/webbeans-impl/src: main/java/org/apache/webbeans/event/NotificationManager.java test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
Date Fri, 08 Jan 2016 11:05:02 GMT
Author: struberg
Date: Fri Jan  8 11:05:02 2016
New Revision: 1723685

URL: http://svn.apache.org/viewvc?rev=1723685&view=rev
Log:
OWB-1102 fix generic assignability check for ProcessInjectionPoint event

txs to Antonin Stefanutti for the bug report and providing a draft for a unit test!

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
  (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java

Modified: openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java?rev=1723685&r1=1723684&r2=1723685&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/event/NotificationManager.java
Fri Jan  8 11:05:02 2016
@@ -531,7 +531,7 @@ public final class NotificationManager
             if(checkEventTypeParameterForExtensions(beanClass, actualArgs[0])
                     && (secondParam == null || actualArgs.length == 1
                             || checkEventTypeParameterForExtensions(secondParam, actualArgs[1])
-                            || GenericsUtil.isAssignableFrom(false, false, secondParam, actualArgs[1])))
+                            || GenericsUtil.isAssignableFrom(false, false, actualArgs[1],
secondParam)))
             {
                 addToMatching(type, matching);   
             }

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java?rev=1723685&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
Fri Jan  8 11:05:02 2016
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.webbeans.test.events.injectiontarget;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessInjectionPoint;
+import javax.inject.Inject;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ProcessInjectionPointTest extends AbstractUnitTest
+{
+
+    @Test
+    public void testConsumerAScanning()
+    {
+        TestExtension extension = new TestExtension();
+        addExtension(extension);
+        startContainer(X.class, A.class, B.class, ConsumerA.class);
+
+        Assert.assertTrue(extension.isXInjectionPointParsed());
+        Assert.assertTrue(extension.isAInjectionPointParsed());
+
+        Assert.assertFalse(extension.isBInjectionPointParsed());
+        Assert.assertFalse(extension.isOtherInjectionPointParsed());
+    }
+
+    @Test
+    public void testConsumerBScanning()
+    {
+        TestExtension extension = new TestExtension();
+        addExtension(extension);
+        startContainer(X.class, A.class, B.class, ConsumerB.class);
+
+        Assert.assertTrue(extension.isXInjectionPointParsed());
+        Assert.assertTrue(extension.isAInjectionPointParsed());
+        Assert.assertTrue(extension.isBInjectionPointParsed());
+
+        Assert.assertFalse(extension.isOtherInjectionPointParsed());
+    }
+
+
+    @Dependent
+    public static class X
+    {
+        // no content
+    }
+
+    @Dependent
+    public static class A extends X
+    {
+        // no content
+    }
+
+    @Dependent
+    @Typed(B.class)
+    public static class B extends A
+    {
+
+    }
+
+    @Dependent
+    public static class ConsumerA
+    {
+        private @Inject A a;
+    }
+
+    @Dependent
+    public static class ConsumerB
+    {
+        private @Inject B b;
+    }
+
+    public static class TestExtension implements Extension
+    {
+        private boolean xInjectionPointParsed = false;
+        private boolean aInjectionPointParsed = false;
+        private boolean bInjectionPointParsed = false;
+        private boolean otherInjectionPointParsed = false;
+
+        void testX(@Observes ProcessInjectionPoint<?, X> pip)
+        {
+            xInjectionPointParsed = true;
+        }
+
+        void testA(@Observes ProcessInjectionPoint<?, A> pip)
+        {
+            aInjectionPointParsed = true;
+        }
+
+        void testB(@Observes ProcessInjectionPoint<?, B> pip)
+        {
+            bInjectionPointParsed = true;
+        }
+
+        void testOther(@Observes ProcessInjectionPoint<?, String> pip)
+        {
+            otherInjectionPointParsed = true;
+        }
+
+
+        public boolean isXInjectionPointParsed()
+        {
+            return xInjectionPointParsed;
+        }
+
+        public boolean isAInjectionPointParsed()
+        {
+            return aInjectionPointParsed;
+        }
+
+
+        public boolean isBInjectionPointParsed()
+        {
+            return bInjectionPointParsed;
+        }
+
+        public boolean isOtherInjectionPointParsed()
+        {
+            return otherInjectionPointParsed;
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/events/injectiontarget/ProcessInjectionPointTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message