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 2023/01/24 18:07:19 UTC

[openwebbeans] 02/03: OWB-1417 fix atinject TCK

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

commit f7411b833da3bb3dfb7abbec70272a618f4beb2c
Author: Mark Struberg <st...@apache.org>
AuthorDate: Tue Jan 24 19:06:02 2023 +0100

    OWB-1417 fix atinject TCK
---
 atinject-tck/pom.xml                               | 23 ++++------
 ...roducer.java => AtinjectTckSetupExtension.java} | 52 ++++++----------------
 .../atinject/tck/specific/SpecificProducer.java    | 11 ++---
 .../webbeans/atinject/tck/specific/TckNew.java     | 37 +++++++++++++++
 .../jakarta.enterprise.inject.spi.Extension        | 18 ++++++++
 pom.xml                                            |  1 +
 6 files changed, 84 insertions(+), 58 deletions(-)

diff --git a/atinject-tck/pom.xml b/atinject-tck/pom.xml
index 56c2ddabf..9847e747d 100644
--- a/atinject-tck/pom.xml
+++ b/atinject-tck/pom.xml
@@ -28,9 +28,9 @@
     </parent>
 
     <artifactId>atinject-tck</artifactId>
-    <name>OWB JSR-330 TCK</name>
+    <name>OWB JSR-330 Jakarta version TCK</name>
     <packaging>jar</packaging>
-    <description>Apache OpenWebBeans JSR-330 TCK Suite</description>
+    <description>Apache OpenWebBeans Jakarta-Inject TCK Suite</description>
 
     <build>
         <plugins>
@@ -52,7 +52,7 @@
         <dependency>
             <groupId>jakarta.inject</groupId>
             <artifactId>jakarta.inject-tck</artifactId>
-            <version>1</version>
+            <version>2.0.1</version>
             <scope>test</scope>
             <exclusions>
                 <exclusion>
@@ -66,34 +66,27 @@
             <groupId>jakarta.annotation</groupId>
             <artifactId>jakarta.annotation-api</artifactId>
         </dependency>
-
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-atinject_1.0_spec</artifactId>
-            <version>${geronimo_atinject.version}</version>
-            <scope>provided</scope>
+            <groupId>jakarta.inject</groupId>
+            <artifactId>jakarta.inject-api</artifactId>
         </dependency>
-
         <dependency>
             <groupId>jakarta.enterprise</groupId>
             <artifactId>jakarta.enterprise.cdi-api</artifactId>
         </dependency>
-        
         <dependency>
             <groupId>jakarta.interceptor</groupId>
             <artifactId>jakarta.interceptor-api</artifactId>
         </dependency>
-        
         <dependency>
-            <groupId>org.apache.geronimo.specs</groupId>
-            <artifactId>geronimo-el_2.2_spec</artifactId>
+            <groupId>jakarta.el</groupId>
+            <artifactId>jakarta.el-api</artifactId>
         </dependency>
-        
+
         <dependency>
             <groupId>org.apache.openwebbeans</groupId>
             <artifactId>openwebbeans-spi</artifactId>
         </dependency>
-        
         <dependency>
             <groupId>org.apache.openwebbeans</groupId>
             <artifactId>openwebbeans-impl</artifactId>
diff --git a/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java b/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/AtinjectTckSetupExtension.java
similarity index 53%
copy from atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java
copy to atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/AtinjectTckSetupExtension.java
index cb10c7a26..44a2ea66c 100644
--- a/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java
+++ b/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/AtinjectTckSetupExtension.java
@@ -18,49 +18,25 @@
  */
 package org.apache.webbeans.atinject.tck.specific;
 
+import jakarta.enterprise.event.Observes;
 import jakarta.enterprise.inject.Typed;
-import jakarta.enterprise.inject.Default;
-import jakarta.enterprise.inject.New;
-import jakarta.enterprise.inject.Produces;
-import jakarta.inject.Named;
-
-import org.atinject.tck.auto.Drivers;
+import jakarta.enterprise.util.AnnotationLiteral;
+import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
+import jakarta.enterprise.inject.spi.Extension;
 import org.atinject.tck.auto.DriversSeat;
-import org.atinject.tck.auto.Seat;
 import org.atinject.tck.auto.accessories.SpareTire;
 
-
-public class SpecificProducer
+/**
+ * Fixes some setup weirdness which got created after removal of @New
+ */
+public class AtinjectTckSetupExtension implements Extension
 {
-    public SpecificProducer()
-    {
-        
-    }
-    
-    @Produces @Drivers
-    public Seat produceDrivers(@New DriversSeat seat)
-    {
-        return seat;
-    }
-    
-    
-    @Produces @DriverBinding @Typed(value={DriversSeat.class})
-    public DriversSeat produceDriverSeat(@New DriversSeat seat)
-    {
-        return seat;
-    }
-    
-    
-    @Produces @Named("spare") @SpareBinding
-    public SpareTire produceSpare(@New SpareTire tire)
+    public void initTckBeans(@Observes BeforeBeanDiscovery bbd)
     {
-        return tire;
-    }
-    
-    @Produces @Default @Typed(value={SpareTire.class})
-    public SpareTire produceSpareTire(@New SpareTire tire)
-    {
-        return tire;
+        bbd.addAnnotatedType(DriversSeat.class, "tck")
+            .add(Typed.Literal.of(new Class[]{DriversSeat.class}));
+
+        bbd.addAnnotatedType(SpareTire.class, "tck")
+            .add(new AnnotationLiteral<TckNew>() {});
     }
-    
 }
diff --git a/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java b/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java
index cb10c7a26..1c54231bf 100644
--- a/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java
+++ b/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/SpecificProducer.java
@@ -18,9 +18,9 @@
  */
 package org.apache.webbeans.atinject.tck.specific;
 
+import jakarta.enterprise.context.ApplicationScoped;
 import jakarta.enterprise.inject.Typed;
 import jakarta.enterprise.inject.Default;
-import jakarta.enterprise.inject.New;
 import jakarta.enterprise.inject.Produces;
 import jakarta.inject.Named;
 
@@ -30,6 +30,7 @@ import org.atinject.tck.auto.Seat;
 import org.atinject.tck.auto.accessories.SpareTire;
 
 
+@ApplicationScoped
 public class SpecificProducer
 {
     public SpecificProducer()
@@ -38,27 +39,27 @@ public class SpecificProducer
     }
     
     @Produces @Drivers
-    public Seat produceDrivers(@New DriversSeat seat)
+    public Seat produceDrivers(DriversSeat seat)
     {
         return seat;
     }
     
     
     @Produces @DriverBinding @Typed(value={DriversSeat.class})
-    public DriversSeat produceDriverSeat(@New DriversSeat seat)
+    public DriversSeat produceDriverSeat(DriversSeat seat)
     {
         return seat;
     }
     
     
     @Produces @Named("spare") @SpareBinding
-    public SpareTire produceSpare(@New SpareTire tire)
+    public SpareTire produceSpare(SpareTire tire)
     {
         return tire;
     }
     
     @Produces @Default @Typed(value={SpareTire.class})
-    public SpareTire produceSpareTire(@New SpareTire tire)
+    public SpareTire produceSpareTire(@TckNew SpareTire tire)
     {
         return tire;
     }
diff --git a/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/TckNew.java b/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/TckNew.java
new file mode 100644
index 000000000..8aa02c807
--- /dev/null
+++ b/atinject-tck/src/test/java/org/apache/webbeans/atinject/tck/specific/TckNew.java
@@ -0,0 +1,37 @@
+/*
+ * 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.atinject.tck.specific;
+
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import jakarta.inject.Qualifier;
+
+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;
+
+@Target({METHOD, TYPE, PARAMETER})
+@Retention(RUNTIME)
+@Qualifier
+public @interface TckNew
+{
+}
diff --git a/atinject-tck/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension b/atinject-tck/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
new file mode 100644
index 000000000..d7dc824b8
--- /dev/null
+++ b/atinject-tck/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
@@ -0,0 +1,18 @@
+#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.
+
+org.apache.webbeans.atinject.tck.specific.AtinjectTckSetupExtension
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 9b3421bd9..a3f206177 100644
--- a/pom.xml
+++ b/pom.xml
@@ -764,6 +764,7 @@
         <module>webbeans-gradle</module>
         <module>webbeans-junit5</module>
         <module>webbeans-porting</module>
+        <module>atinject-tck</module>
 <!--X TODO re-enable
         <module>webbeans-ee-common</module>
         <module>webbeans-ee</module>