From b511cf0c41ef01a8c4ea4809854b15f33b9c5b42 Mon Sep 17 00:00:00 2001 From: Thomas Andraschko Date: Mon, 18 Mar 2024 16:01:21 +0100 Subject: [PATCH] workaround that payara doesnt pass cdicontainer.version to single tests --- .../uc007/MethodLevelInterceptorTest.java | 19 +++++++++++++++++++ .../uc008/ClassLevelInterceptorTest.java | 17 +++++++++++++++-- .../uc013/MethodLevelInterceptorTest.java | 7 +++++++ .../src/main/resources/arquillian.xml | 3 +-- 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java index 3ceacc431..8d9b5d1ec 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc007/MethodLevelInterceptorTest.java @@ -19,6 +19,7 @@ package org.apache.deltaspike.test.core.api.partialbean.uc007; import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.core.util.ClassUtils; import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl; import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorState; import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; @@ -77,6 +78,12 @@ public void testMethodLevelInterceptor() throws Exception // this test is known to not work under weld-5.0.x Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_5_0)); + // workaround as payara doesnt pass cdicontainer.version to the arquillian process + if (ClassUtils.tryToLoadClassForName("org.apache.deltaspike.test.core.api.partialbean.uc007.PartialBean") == null) + { + return; + } + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); @@ -91,6 +98,12 @@ public void testMethodLevelInterceptorStereotype() throws Exception // this test is known to not work under weld-5.0.x Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_5_0)); + // workaround as payara doesnt pass cdicontainer.version to the arquillian process + if (ClassUtils.tryToLoadClassForName("org.apache.deltaspike.test.core.api.partialbean.uc007.PartialBean") == null) + { + return; + } + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); @@ -105,6 +118,12 @@ public void testMethodLevelInterceptorOnAbstractMethod() throws Exception // this test is known to not work under weld-5.0.x Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_5_0)); + // workaround as payara doesnt pass cdicontainer.version to the arquillian process + if (ClassUtils.tryToLoadClassForName("org.apache.deltaspike.test.core.api.partialbean.uc007.PartialBean") == null) + { + return; + } + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java index ba9dbca5c..cbcfdfec3 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc008/ClassLevelInterceptorTest.java @@ -18,9 +18,10 @@ */ package org.apache.deltaspike.test.core.api.partialbean.uc008; +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.core.util.ClassUtils; import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorImpl; import org.apache.deltaspike.test.core.api.partialbean.shared.CustomInterceptorState; -import org.apache.deltaspike.core.api.provider.BeanProvider; import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; import org.apache.deltaspike.test.utils.CdiContainerUnderTest; @@ -77,6 +78,12 @@ public void testClassLevelInterceptor() throws Exception // this test is known to not work under weld-5.0.x Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_5_0)); + // workaround as payara doesnt pass cdicontainer.version to the arquillian process + if (ClassUtils.tryToLoadClassForName("org.apache.deltaspike.test.core.api.partialbean.uc008.PartialBean") == null) + { + return; + } + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); @@ -92,7 +99,13 @@ public void testClassLevelInterceptorOnAbstractMethod() throws Exception // this test is known to not work under weld-5.0.x Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_5_0)); - PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class); + // workaround as payara doesnt pass cdicontainer.version to the arquillian process + if (ClassUtils.tryToLoadClassForName("org.apache.deltaspike.test.core.api.partialbean.uc008.PartialBean") == null) + { + return; + } + + PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class, true); CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class); Assert.assertNotNull(partialBean); diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc013/MethodLevelInterceptorTest.java b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc013/MethodLevelInterceptorTest.java index 21aa42275..e7a1fc2d6 100644 --- a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc013/MethodLevelInterceptorTest.java +++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc013/MethodLevelInterceptorTest.java @@ -20,6 +20,7 @@ import jakarta.enterprise.inject.spi.Extension; import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.core.util.ClassUtils; import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding; import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils; import org.apache.deltaspike.test.utils.CdiContainerUnderTest; @@ -79,6 +80,12 @@ public void testMethodLevelInterceptor() throws Exception // this test is known to not work under weld Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD)); + // workaround as payara doesnt pass cdicontainer.version to the arquillian process + if (ClassUtils.tryToLoadClassForName("org.apache.deltaspike.test.core.api.partialbean.uc013.MyRepository") == null) + { + return; + } + MyRepository myRepository = BeanProvider.getContextualReference(MyRepository.class); List users = myRepository.getAllUsers(); diff --git a/deltaspike/test-utils/src/main/resources/arquillian.xml b/deltaspike/test-utils/src/main/resources/arquillian.xml index 7219826d3..c2d04d225 100644 --- a/deltaspike/test-utils/src/main/resources/arquillian.xml +++ b/deltaspike/test-utils/src/main/resources/arquillian.xml @@ -66,7 +66,7 @@ -1 -1 target/arquillian-test-working-dir - -Dcdicontainer.version=tomee-${tomee.version} + -Dcdicontainer.version=${cdicontainer.version} true @@ -94,5 +94,4 @@ -