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 c204f452c01889ae14ce4badd29724548ffc2cfd Author: Mark Struberg <strub...@apache.org> AuthorDate: Wed Jan 25 15:43:29 2023 +0100 OWB1417 explicit test for @Priority on Interceptor --- bom/openwebbeans-se-bom/pom.xml | 161 ++++++++++----------- webbeans-impl/src/it/properties/pom.xml | 11 -- .../webbeans/config/OpenWebBeansConfiguration.java | 4 +- .../interceptors/priority/InterceptedBean.java | 31 ++++ .../priority/NotPriorityActivatedInterceptor.java | 39 +++++ .../priority/PriorityActivatedInterceptor.java | 41 ++++++ .../PriorityActivatedInterceptorBinding.java | 36 +++++ .../priority/PriorityActivatedInterceptorTest.java | 57 ++++++++ webbeans-tck/pom.xml | 5 + .../META-INF/openwebbeans/openwebbeans.properties | 2 +- webbeans-tck/testng-dev.xml | 7 +- webbeans-tomcat/pom.xml | 9 +- webbeans-tomcat/src/it/servletinjection/pom.xml | 22 +-- 13 files changed, 313 insertions(+), 112 deletions(-) diff --git a/bom/openwebbeans-se-bom/pom.xml b/bom/openwebbeans-se-bom/pom.xml index edc25b6b2..2a453ead5 100644 --- a/bom/openwebbeans-se-bom/pom.xml +++ b/bom/openwebbeans-se-bom/pom.xml @@ -16,91 +16,84 @@ License. --> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <parent> - <artifactId>bom</artifactId> - <groupId>org.apache.openwebbeans.bom</groupId> - <version>4.0.0-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>bom</artifactId> + <groupId>org.apache.openwebbeans.bom</groupId> + <version>4.0.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> - <artifactId>openwebbeans-se-bom</artifactId> - <name>SE BOM</name> - <description>Apache OpenWebBeans SE BOM</description> - <packaging>pom</packaging> + <artifactId>openwebbeans-se-bom</artifactId> + <name>SE BOM</name> + <description>Apache OpenWebBeans SE BOM</description> + <packaging>pom</packaging> - <dependencies> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-annotation_1.3_spec</artifactId> - <version>${geronimo_annotation.version}</version> - <classifier>jakarta</classifier> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jcdi_2.0_spec</artifactId> - <version>${geronimo_cdi.version}</version> - <classifier>jakarta</classifier> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-atinject_1.0_spec</artifactId> - <version>${geronimo_atinject.version}</version> - <classifier>jakarta</classifier> - </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-interceptor_1.2_spec</artifactId> - <version>${geronimo_interceptor.version}</version> - <classifier>jakarta</classifier> - </dependency> + <dependencies> + <dependency> + <groupId>jakarta.annotation</groupId> + <artifactId>jakarta.annotation-api</artifactId> + </dependency> + <dependency> + <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> + <scope>test</scope> + </dependency> - <dependency> - <groupId>org.apache.openwebbeans</groupId> - <artifactId>openwebbeans-spi</artifactId> - <version>${project.version}</version> - <classifier>jakarta</classifier> - <exclusions> - <exclusion> - <groupId>org.apache.openwebbeans</groupId> - <artifactId>*</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.openwebbeans</groupId> - <artifactId>openwebbeans-impl</artifactId> - <version>${project.version}</version> - <classifier>jakarta</classifier> - <exclusions> - <exclusion> - <groupId>org.apache.openwebbeans</groupId> - <artifactId>*</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.openwebbeans</groupId> - <artifactId>openwebbeans-se</artifactId> - <version>${project.version}</version> - <classifier>jakarta</classifier> - <exclusions> - <exclusion> - <groupId>org.apache.openwebbeans</groupId> - <artifactId>*</artifactId> - </exclusion> - <exclusion> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>*</artifactId> - </exclusion> - </exclusions> - </dependency> - </dependencies> + <dependency> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>openwebbeans-spi</artifactId> + <version>${project.version}</version> + <classifier>jakarta</classifier> + <exclusions> + <exclusion> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>openwebbeans-impl</artifactId> + <version>${project.version}</version> + <classifier>jakarta</classifier> + <exclusions> + <exclusion> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>openwebbeans-se</artifactId> + <version>${project.version}</version> + <classifier>jakarta</classifier> + <exclusions> + <exclusion> + <groupId>org.apache.openwebbeans</groupId> + <artifactId>*</artifactId> + </exclusion> + <exclusion> + <groupId>org.apache.geronimo.specs</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + </dependencies> </project> \ No newline at end of file diff --git a/webbeans-impl/src/it/properties/pom.xml b/webbeans-impl/src/it/properties/pom.xml index cb43576b6..29408dcf9 100644 --- a/webbeans-impl/src/it/properties/pom.xml +++ b/webbeans-impl/src/it/properties/pom.xml @@ -41,17 +41,6 @@ <version>@pom.version@</version> </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jcdi_2.0_spec</artifactId> - <optional>true</optional> - </dependency> - - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-atinject_1.0_spec</artifactId> - <optional>true</optional> - </dependency> <dependency> <groupId>jakarta.annotation</groupId> <artifactId>jakarta.annotation-api</artifactId> diff --git a/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java b/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java index b2b2f1a15..d692e4296 100644 --- a/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java +++ b/webbeans-impl/src/main/java/org/apache/webbeans/config/OpenWebBeansConfiguration.java @@ -581,12 +581,12 @@ public class OpenWebBeansConfiguration final String conf = getProperty("org.apache.webbeans.generator.proxyReservedPackages"); if (conf == null) { - proxyReservedPackages = asList("java.", "javax.", "sun.misc."); + proxyReservedPackages = asList("java.", "javax.", "jakarta.", "sun.misc."); } else { proxyReservedPackages = Stream.concat( - Stream.of("java.", "javax.", "sun.misc."), + Stream.of("java.", "javax.", "jakarta.", "sun.misc."), Stream.of(conf.split(",")) .map(String::trim) .filter(it -> !it.isEmpty())) diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/InterceptedBean.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/InterceptedBean.java new file mode 100644 index 000000000..b1680ba3c --- /dev/null +++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/InterceptedBean.java @@ -0,0 +1,31 @@ +/* + * 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.interceptors.priority; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptedBean +{ + @PriorityActivatedInterceptorBinding + public String andYouSay() + { + return "yesyesyes"; + } +} diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/NotPriorityActivatedInterceptor.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/NotPriorityActivatedInterceptor.java new file mode 100644 index 000000000..4fd4151dd --- /dev/null +++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/NotPriorityActivatedInterceptor.java @@ -0,0 +1,39 @@ +/* + * 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.interceptors.priority; + +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; + +/** + * + */ +@Interceptor +@PriorityActivatedInterceptorBinding +public class NotPriorityActivatedInterceptor +{ + + @AroundInvoke + public Object caller(InvocationContext context) throws Exception + { + return "nonono"; + } + +} diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptor.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptor.java new file mode 100644 index 000000000..168f9dcf3 --- /dev/null +++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptor.java @@ -0,0 +1,41 @@ +/* + * 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.interceptors.priority; + +import jakarta.annotation.Priority; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; + +/** + * + */ +@Interceptor +@PriorityActivatedInterceptorBinding +@Priority(1000) +public class PriorityActivatedInterceptor +{ + + @AroundInvoke + public Object caller(InvocationContext context) throws Exception + { + return "nonono"; + } + +} diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptorBinding.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptorBinding.java new file mode 100644 index 000000000..aa7a90188 --- /dev/null +++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptorBinding.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.interceptors.priority; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import jakarta.interceptor.InterceptorBinding; + +/** + * + */ +@InterceptorBinding +@Retention(RetentionPolicy.RUNTIME) +@Target( { ElementType.TYPE, ElementType.METHOD }) +public @interface PriorityActivatedInterceptorBinding +{ +} diff --git a/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptorTest.java b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptorTest.java new file mode 100644 index 000000000..b4f849912 --- /dev/null +++ b/webbeans-impl/src/test/java/org/apache/webbeans/test/interceptors/priority/PriorityActivatedInterceptorTest.java @@ -0,0 +1,57 @@ +/* + * 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.interceptors.priority; + +import org.apache.webbeans.test.AbstractUnitTest; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * Test enabling of Interceptors via the @Priority annotation + */ +public class PriorityActivatedInterceptorTest extends AbstractUnitTest +{ + + @Test + public void testNotEnabledInterceptor() + { + startContainer( + InterceptedBean.class, + NotPriorityActivatedInterceptor.class, + PriorityActivatedInterceptorBinding.class, + InterceptedBean.class); + + final InterceptedBean interceptedBean = getInstance(InterceptedBean.class); + assertEquals("yesyesyes", interceptedBean.andYouSay()); + } + + @Test + public void testEnabledInterceptor() + { + startContainer( + InterceptedBean.class, + PriorityActivatedInterceptor.class, + PriorityActivatedInterceptorBinding.class, + InterceptedBean.class); + + final InterceptedBean interceptedBean = getInstance(InterceptedBean.class); + assertEquals("nonono", interceptedBean.andYouSay()); + } +} diff --git a/webbeans-tck/pom.xml b/webbeans-tck/pom.xml index 70bca227d..cad7b4770 100644 --- a/webbeans-tck/pom.xml +++ b/webbeans-tck/pom.xml @@ -49,6 +49,11 @@ <!-- Those dependencies are required for standalone TCK testing --> + + <dependency> + <groupId>jakarta.annotation</groupId> + <artifactId>jakarta.annotation-api</artifactId> + </dependency> <dependency> <groupId>jakarta.interceptor</groupId> <artifactId>jakarta.interceptor-api</artifactId> diff --git a/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties b/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties index 1ed02da0b..dca603680 100644 --- a/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties +++ b/webbeans-tck/src/main/resources/META-INF/openwebbeans/openwebbeans.properties @@ -38,7 +38,7 @@ org.apache.webbeans.application.supportsConversation=true # we have to switch back to the un-cached version of the normal scoping handler org.apache.webbeans.proxy.mapping.jakarta.enterprise.context.ApplicationScoped=org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler -org.apache.webbeans.proxy.mapping.jakarta.enterprise.context.ApplicationScoped=org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler +org.apache.webbeans.proxy.mapping.jakarta.enterprise.context.RequestScoped=org.apache.webbeans.intercept.NormalScopedBeanInterceptorHandler org.apache.webbeans.container.InjectionResolver.fastMatching = false diff --git a/webbeans-tck/testng-dev.xml b/webbeans-tck/testng-dev.xml index 7894cbeae..67ebf00dd 100644 --- a/webbeans-tck/testng-dev.xml +++ b/webbeans-tck/testng-dev.xml @@ -18,7 +18,12 @@ <suite name="JSR-346-TCK" verbose="2" configfailurepolicy="continue"> <test name="JSR-346 TCK"> <classes> - <class name="org.jboss.cdi.tck.tests.extensions.beanManager.beanAttributes.CreateBeanAttributesTest" /> + <class name="org.jboss.cdi.tck.interceptors.tests.contract.invocationContext.InvocationContextTest" > + <methods> + <include name="testBusinessMethodNotCalledWithoutProceedInvocation"/> + </methods> + </class> + <!-- <class name="org.jboss.cdi.tck.tests.event.parameterized.ParameterizedEventTest" /> diff --git a/webbeans-tomcat/pom.xml b/webbeans-tomcat/pom.xml index e3b0e3623..ed72d3566 100644 --- a/webbeans-tomcat/pom.xml +++ b/webbeans-tomcat/pom.xml @@ -27,14 +27,19 @@ <name>Tomcat plugin</name> <dependencies> + <dependency> - <groupId>jakarta.enterprise</groupId> - <artifactId>jakarta.enterprise.cdi-api</artifactId> + <groupId>jakarta.annotation</groupId> + <artifactId>jakarta.annotation-api</artifactId> </dependency> <dependency> <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> diff --git a/webbeans-tomcat/src/it/servletinjection/pom.xml b/webbeans-tomcat/src/it/servletinjection/pom.xml index 87d891eaa..9f38c8c5c 100644 --- a/webbeans-tomcat/src/it/servletinjection/pom.xml +++ b/webbeans-tomcat/src/it/servletinjection/pom.xml @@ -228,21 +228,21 @@ </dependency> <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-jcdi_2.0_spec</artifactId> - <version>1.0</version> + <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>1.0</version> + <groupId>jakarta.inject</groupId> + <artifactId>jakarta.inject-api</artifactId> + </dependency> + <dependency> + <groupId>jakarta.enterprise</groupId> + <artifactId>jakarta.enterprise.cdi-api</artifactId> </dependency> - <dependency> - <groupId>org.apache.geronimo.specs</groupId> - <artifactId>geronimo-interceptor_1.2_spec</artifactId> - <version>${geronimo_interceptor.version}</version> + <groupId>jakarta.interceptor</groupId> + <artifactId>jakarta.interceptor-api</artifactId> + <scope>test</scope> </dependency> </dependencies> </plugin>