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 d7a9f81c2 unit test for beanscanning of classes with a NoClassDefFound
d7a9f81c2 is described below
commit d7a9f81c2a787929eb54c79aa481b5fb8889a8b9
Author: Mark Struberg <[email protected]>
AuthorDate: Wed Jun 17 18:53:09 2026 +0200
unit test for beanscanning of classes with a NoClassDefFound
---
.../component/classscanning/AvailableBean.java | 31 +++++++++++++
.../test/component/classscanning/NcdfClassA.java | 25 +++++++++++
.../test/component/classscanning/NcdfClassB.java | 30 +++++++++++++
.../classscanning/NoClassDefFoundHandlingTest.java | 52 ++++++++++++++++++++++
4 files changed, 138 insertions(+)
diff --git
a/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/AvailableBean.java
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/AvailableBean.java
new file mode 100644
index 000000000..49bfb4b33
--- /dev/null
+++
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/AvailableBean.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.component.classscanning;
+
+import jakarta.enterprise.context.ApplicationScoped;
+
+/**
+ * This bean is just to verify that the container works for properly setup
beans.
+ */
+@ApplicationScoped
+public class AvailableBean
+{
+ public int meaningOfLife()
+ {
+ return 42;
+ }
+}
diff --git
a/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NcdfClassA.java
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NcdfClassA.java
new file mode 100644
index 000000000..1c1568e02
--- /dev/null
+++
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NcdfClassA.java
@@ -0,0 +1,25 @@
+/*
+ * 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.component.classscanning;
+
+public class NcdfClassA
+{
+ public int meaningOfLife()
+ {
+ return 42;
+ }
+}
diff --git
a/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NcdfClassB.java
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NcdfClassB.java
new file mode 100644
index 000000000..dd7158c08
--- /dev/null
+++
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NcdfClassB.java
@@ -0,0 +1,30 @@
+/*
+ * 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.component.classscanning;
+
+import jakarta.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+public class NcdfClassB
+{
+ private NcdfClassA ncdfClassA = new NcdfClassA();
+
+ public int meaningOfLife()
+ {
+ return ncdfClassA.meaningOfLife();
+ }
+}
diff --git
a/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NoClassDefFoundHandlingTest.java
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NoClassDefFoundHandlingTest.java
new file mode 100644
index 000000000..7caf9d402
--- /dev/null
+++
b/webbeans-impl/src/test/java/org/apache/webbeans/test/component/classscanning/NoClassDefFoundHandlingTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.component.classscanning;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.webbeans.test.AbstractUnitTest;
+import org.junit.Test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Test scanning of a class which cannot
+ */
+public class NoClassDefFoundHandlingTest extends AbstractUnitTest
+{
+
+ @Test
+ public void testNoClassDefFoundHandling()
+ {
+ deleteClassFile(this.getClass().getPackageName() + ".NcdfClassA");
+ startContainer(NcdfClassB.class, AvailableBean.class);
+
+ assertNotNull(getBean(AvailableBean.class));
+ assertNull(getBean(NcdfClassB.class));
+ }
+
+ private void deleteClassFile(String className)
+ {
+ String classResourceName = "/" + className.replace('.', '/') +
".class";
+ final URL classRessource =
this.getClass().getResource(classResourceName);
+ if (classRessource != null) {
+ new File(classRessource.getFile()).delete();
+ }
+ }
+}