Skip to content

Commit

Permalink
workaround that payara doesnt pass cdicontainer.version to single tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tandraschko committed Mar 18, 2024
1 parent 1e79f8f commit b511cf0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> users = myRepository.getAllUsers();
Expand Down
3 changes: 1 addition & 2 deletions deltaspike/test-utils/src/main/resources/arquillian.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<property name="ajpPort">-1</property>
<property name="stopPort">-1</property>
<property name="appWorkingDir">target/arquillian-test-working-dir</property>
<property name="catalina_opts">-Dcdicontainer.version=tomee-${tomee.version}</property>
<property name="catalina_opts">-Dcdicontainer.version=${cdicontainer.version}</property>
<property name="simpleLog">true</property>

<!-- In-Memory database for the data module -->
Expand Down Expand Up @@ -94,5 +94,4 @@
</configuration>
</container>


</arquillian>

0 comments on commit b511cf0

Please sign in to comment.