This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openwebbeans.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c42bea00 OWB-1418 @Priority on Alternative Sterotypes enables bean
4c42bea00 is described below

commit 4c42bea0041b70f788d9e5e4d900199d939e9de4
Author: Mark Struberg <strub...@apache.org>
AuthorDate: Wed Jan 25 19:43:59 2023 +0100

    OWB-1418 @Priority on Alternative Sterotypes enables bean
---
 .../org/apache/webbeans/util/WebBeansUtil.java     |  5 +--
 .../unittests/xml/strict/AlternativesTest.java     | 12 ++++++++
 .../webbeans/test/xml/strict/Alternative4.java     | 26 ++++++++++++++++
 .../strict/AlternativeStereotypeWithPriority.java  | 36 ++++++++++++++++++++++
 webbeans-tck/standalone-suite.xml                  | 15 +++------
 webbeans-tck/testng-dev.xml                        |  2 +-
 6 files changed, 82 insertions(+), 14 deletions(-)

diff --git 
a/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java 
b/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
index 0aa876d57..3e279805d 100644
--- a/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
+++ b/webbeans-impl/src/main/java/org/apache/webbeans/util/WebBeansUtil.java
@@ -900,11 +900,12 @@ public final class WebBeansUtil
         {
             return true;
         }
-        if (stereotypes != null && !stereotypes.isEmpty() && 
at.getAnnotation(Priority.class) != null)
+        if (stereotypes != null && !stereotypes.isEmpty())
         {
             for (Class<? extends Annotation> stereotype : stereotypes)
             {
-                if (alternativesManager.isAlternativeStereotype(stereotype))
+                if (alternativesManager.isAlternativeStereotype(stereotype) &&
+                    (at.getAnnotation(Priority.class) != null || 
stereotype.getAnnotation(Priority.class) != null))
                 {
                     return true;
                 }
diff --git 
a/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
index 3c3364da7..b2c6f9351 100644
--- 
a/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
+++ 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/xml/strict/AlternativesTest.java
@@ -22,7 +22,9 @@ package org.apache.webbeans.test.unittests.xml.strict;
 import jakarta.enterprise.inject.spi.Bean;
 
 import org.apache.webbeans.test.xml.strict.Alternative3;
+import org.apache.webbeans.test.xml.strict.Alternative4;
 import org.apache.webbeans.test.xml.strict.AlternativeStereotype;
+import org.apache.webbeans.test.xml.strict.AlternativeStereotypeWithPriority;
 import org.apache.webbeans.test.xml.strict.OriginalBean;
 import org.apache.webbeans.test.xml.strict.SomeInterface;
 import org.junit.Assert;
@@ -65,6 +67,16 @@ public class AlternativesTest extends AbstractUnitTest
         Assert.assertTrue(instance instanceof Alternative3);
     }
     
+    @Test
+    public void testPriorityOnSterotypeEnabledAlternative()
+    {
+        startContainer(Alternative4.class, 
AlternativeStereotypeWithPriority.class, OriginalBean.class);
+
+        SomeInterface instance = getInstance(SomeInterface.class);
+        Assert.assertNotNull(instance);
+        Assert.assertTrue(instance instanceof Alternative4);
+    }
+
     @Test(expected=WebBeansConfigurationException.class)
     public void testDoubleAlternativeClass()
     {        
diff --git 
a/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative4.java
 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative4.java
new file mode 100644
index 000000000..faec6806f
--- /dev/null
+++ 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/Alternative4.java
@@ -0,0 +1,26 @@
+/*
+ * 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.xml.strict;
+
+
+@AlternativeStereotypeWithPriority
+public class Alternative4 implements SomeInterface
+{
+
+}
diff --git 
a/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotypeWithPriority.java
 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotypeWithPriority.java
new file mode 100644
index 000000000..de1708d5b
--- /dev/null
+++ 
b/webbeans-impl/src/test/java/org/apache/webbeans/test/xml/strict/AlternativeStereotypeWithPriority.java
@@ -0,0 +1,36 @@
+/*
+ * 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.xml.strict;
+
+import java.lang.annotation.Retention;
+
+import jakarta.annotation.Priority;
+import jakarta.enterprise.inject.Alternative;
+import jakarta.enterprise.inject.Stereotype;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+@Alternative
+@Retention(RUNTIME)
+@Priority(1000)
+public @interface AlternativeStereotypeWithPriority
+{
+
+}
diff --git a/webbeans-tck/standalone-suite.xml 
b/webbeans-tck/standalone-suite.xml
index ecb30c2b0..98ac8e10d 100644
--- a/webbeans-tck/standalone-suite.xml
+++ b/webbeans-tck/standalone-suite.xml
@@ -47,7 +47,10 @@
 
                 <!--X TODO OWB-1182 CDI 2.0 exlcuded for now - current focus 
on ee -->
                 <exclude name="org.jboss.cdi.tck.tests.se.*" />
+
+                <!-- Tests which do require a BuildCompatibleExtension and 
thus do not run with OWB-4.0 yet -->
                 <exclude 
name="org.jboss.cdi.tck.tests.build.compatible.*"></exclude>
+                <exclude 
name="org.jboss.cdi.tck.tests.full.extensions.lite.*"></exclude>
             </package>
 
             <package name="org.jboss.cdi.tck.interceptors.tests.*"/>
@@ -56,17 +59,7 @@
 
 
         <classes>
-            <!-- Tests which do require a BuildCompatibleExtension and thus do 
not run with OWB-4.0 yet -->
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.syntheticBeanWithLookup.SyntheticBeanWithLookupTest"><methods><exclude
 name=".*"/></methods></class>
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.changeBeanQualifier.ChangeBeanQualifierTest"><methods><exclude
 name=".*"/></methods></class>
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.changeInjectionPoint.ChangeInjectionPointTest"><methods><exclude
 name=".*"/></methods></class>
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.changeObserverQualifier.ChangeObserverQualifierTest"><methods><exclude
 name=".*"/></methods></class>
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.customQualifier.CustomQualifierTest"><methods><exclude
 name=".*"/></methods></class>
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.customStereotype.CustomStereotypeTest"><methods><exclude
 name=".*"/></methods></class>
-            <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.invalid.EnhancementMultipleParamsTest"><methods><exclude
 name=".*"/></methods></class>
-
-            
-            
+
             <!-- Tests broken in the CDI-2.0 TCK: -->
 
             <!-- https://issues.jboss.org/projects/CDITCK/issues/CDITCK-576 -->
diff --git a/webbeans-tck/testng-dev.xml b/webbeans-tck/testng-dev.xml
index 60a2bde40..faf844c3e 100644
--- a/webbeans-tck/testng-dev.xml
+++ b/webbeans-tck/testng-dev.xml
@@ -18,7 +18,7 @@
 <suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue">
   <test name="JSR-346 TCK">
     <classes>
-          <class 
name="org.jboss.cdi.tck.tests.build.compatible.extensions.syntheticBeanWithLookup.SyntheticBeanWithLookupTest"
 >
+          <class 
name="org.jboss.cdi.tck.tests.definition.stereotype.priority.StereotypeWithPriorityTest"
 >
             <methods>
               <include name=".*"/>
             </methods>

Reply via email to