This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits 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 fce73e279 OWB-1463 add integration test for performance edge cases
fce73e279 is described below
commit fce73e279ed4991f371933fac45b6fc0c8e05280
Author: Mark Struberg <[email protected]>
AuthorDate: Mon Jul 6 17:05:09 2026 +0200
OWB-1463 add integration test for performance edge cases
---
.../src/it/duplicateannotatedtypes/pom.xml | 66 +++++++++++
.../deployer/DuplicateAnnotatedTypeExtension.java | 122 +++++++++++++++++++++
.../DuplicateAnnotatedTypesAlternativeTest.java | 79 +++++++++++++
.../src/test/resources/META-INF/beans.xml | 23 ++++
.../jakarta.enterprise.inject.spi.Extension | 18 +++
5 files changed, 308 insertions(+)
diff --git a/webbeans-impl/src/it/duplicateannotatedtypes/pom.xml
b/webbeans-impl/src/it/duplicateannotatedtypes/pom.xml
new file mode 100644
index 000000000..38e749d2f
--- /dev/null
+++ b/webbeans-impl/src/it/duplicateannotatedtypes/pom.xml
@@ -0,0 +1,66 @@
+<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/maven-v4_0_0.xsd">
+<!--
+
+ 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.
+-->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans</artifactId>
+ <version>@pom.version@</version>
+ </parent>
+
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl-it-duplicateannotatedtypes</artifactId>
+ <version>@pom.version@</version>
+
+ <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>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.el</groupId>
+ <artifactId>jakarta.el-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openwebbeans</groupId>
+ <artifactId>openwebbeans-impl</artifactId>
+ <version>@pom.version@</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/webbeans-impl/src/it/duplicateannotatedtypes/src/test/java/org/apache/webbeans/test/spi/deployer/DuplicateAnnotatedTypeExtension.java
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/java/org/apache/webbeans/test/spi/deployer/DuplicateAnnotatedTypeExtension.java
new file mode 100644
index 000000000..a6da22071
--- /dev/null
+++
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/java/org/apache/webbeans/test/spi/deployer/DuplicateAnnotatedTypeExtension.java
@@ -0,0 +1,122 @@
+/*
+ * 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.spi.deployer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.Alternative;
+import jakarta.enterprise.inject.spi.AnnotatedConstructor;
+import jakarta.enterprise.inject.spi.AnnotatedField;
+import jakarta.enterprise.inject.spi.AnnotatedMethod;
+import jakarta.enterprise.inject.spi.AnnotatedType;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
+import jakarta.enterprise.inject.spi.Extension;
+
+public class DuplicateAnnotatedTypeExtension implements Extension
+{
+ public void register(@Observes BeforeBeanDiscovery beforeBeanDiscovery,
BeanManager beanManager)
+ {
+
AnnotatedType<DuplicateAnnotatedTypesAlternativeTest.XmlConfiguredAlternativeBean>
delegate
+ =
beanManager.createAnnotatedType(DuplicateAnnotatedTypesAlternativeTest.XmlConfiguredAlternativeBean.class);
+
+ beforeBeanDiscovery.addAnnotatedType(new
AlternativeAnnotatedType<>(delegate), "alternative");
+ for (int i = 0; i <
DuplicateAnnotatedTypesAlternativeTest.PLAIN_DUPLICATE_COUNT; i++)
+ {
+ beforeBeanDiscovery.addAnnotatedType(delegate, "plain-" + i);
+ }
+ }
+
+ private static class AlternativeAnnotatedType<T> implements
AnnotatedType<T>
+ {
+ private final AnnotatedType<T> delegate;
+ private final Set<Annotation> annotations;
+
+ private AlternativeAnnotatedType(AnnotatedType<T> delegate)
+ {
+ this.delegate = delegate;
+ this.annotations = new LinkedHashSet<>(delegate.getAnnotations());
+ this.annotations.add(Alternative.Literal.INSTANCE);
+ }
+
+ @Override
+ public Class<T> getJavaClass()
+ {
+ return delegate.getJavaClass();
+ }
+
+ @Override
+ public Set<AnnotatedConstructor<T>> getConstructors()
+ {
+ return delegate.getConstructors();
+ }
+
+ @Override
+ public Set<AnnotatedMethod<? super T>> getMethods()
+ {
+ return delegate.getMethods();
+ }
+
+ @Override
+ public Set<AnnotatedField<? super T>> getFields()
+ {
+ return delegate.getFields();
+ }
+
+ @Override
+ public Type getBaseType()
+ {
+ return delegate.getBaseType();
+ }
+
+ @Override
+ public Set<Type> getTypeClosure()
+ {
+ return delegate.getTypeClosure();
+ }
+
+ @Override
+ public <A extends Annotation> A getAnnotation(Class<A> annotationType)
+ {
+ for (Annotation annotation : annotations)
+ {
+ if (annotation.annotationType() == annotationType)
+ {
+ return annotationType.cast(annotation);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Set<Annotation> getAnnotations()
+ {
+ return annotations;
+ }
+
+ @Override
+ public boolean isAnnotationPresent(Class<? extends Annotation>
annotationType)
+ {
+ return getAnnotation(annotationType) != null;
+ }
+ }
+
+}
diff --git
a/webbeans-impl/src/it/duplicateannotatedtypes/src/test/java/org/apache/webbeans/test/spi/deployer/DuplicateAnnotatedTypesAlternativeTest.java
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/java/org/apache/webbeans/test/spi/deployer/DuplicateAnnotatedTypesAlternativeTest.java
new file mode 100644
index 000000000..06a27092c
--- /dev/null
+++
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/java/org/apache/webbeans/test/spi/deployer/DuplicateAnnotatedTypesAlternativeTest.java
@@ -0,0 +1,79 @@
+/*
+ * 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.spi.deployer;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import jakarta.enterprise.event.Observes;
+import jakarta.enterprise.inject.Alternative;
+import jakarta.enterprise.inject.Typed;
+import jakarta.enterprise.inject.spi.AnnotatedConstructor;
+import jakarta.enterprise.inject.spi.AnnotatedField;
+import jakarta.enterprise.inject.spi.AnnotatedMethod;
+import jakarta.enterprise.inject.spi.AnnotatedType;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.enterprise.inject.spi.BeforeBeanDiscovery;
+import jakarta.enterprise.inject.spi.Extension;
+import jakarta.enterprise.inject.spi.CDI;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DuplicateAnnotatedTypesAlternativeTest
+{
+ public static final int PLAIN_DUPLICATE_COUNT = 256;
+
+ @Test
+ public void shouldBootWithXmlAlternativeAndDuplicateAnnotatedTypes()
+ {
+ ContainerLifecycle containerLifecycle =
WebBeansContext.getInstance().getService(ContainerLifecycle.class);
+ containerLifecycle.startApplication(null);
+
+ try
+ {
+
Assert.assertNotNull(CDI.current().select(SelectedType.class).get());
+ }
+ finally
+ {
+ containerLifecycle.stopApplication(null);
+ }
+ }
+
+ public interface SelectedType
+ {
+ String value();
+ }
+
+ // will be made an Alternative via Extension
+ @Typed(SelectedType.class)
+ public static class XmlConfiguredAlternativeBean implements SelectedType
+ {
+ @Override
+ public String value()
+ {
+ return "selected";
+ }
+ }
+
+}
diff --git
a/webbeans-impl/src/it/duplicateannotatedtypes/src/test/resources/META-INF/beans.xml
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/resources/META-INF/beans.xml
new file mode 100644
index 000000000..a10dfe7c8
--- /dev/null
+++
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,23 @@
+<!--
+ 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.
+-->
+<beans>
+ <alternatives>
+
<class>org.apache.webbeans.test.spi.deployer.DuplicateAnnotatedTypesAlternativeTest$XmlConfiguredAlternativeBean</class>
+ </alternatives>
+</beans>
diff --git
a/webbeans-impl/src/it/duplicateannotatedtypes/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
b/webbeans-impl/src/it/duplicateannotatedtypes/src/test/resources/META-INF/services/jakarta.enterprise.inject.spi.Extension
new file mode 100644
index 000000000..62053ab88
--- /dev/null
+++
b/webbeans-impl/src/it/duplicateannotatedtypes/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.test.spi.deployer.DuplicateAnnotatedTypeExtension