Skip to content

Commit

Permalink
Weld5 needs Priority annotation on Interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
shadogray committed Mar 5, 2024
1 parent b033a86 commit b50866e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
package org.apache.deltaspike.test.core.api.partialbean.shared;

import java.io.Serializable;

import jakarta.annotation.Priority;
import jakarta.inject.Inject;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;

@Priority(Interceptor.Priority.APPLICATION)
@Interceptor
@CustomInterceptor
public class CustomInterceptorImpl implements Serializable
Expand Down
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.test.core.api.partialbean.shared.CustomInterceptor;
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 All @@ -39,8 +40,6 @@
@RunWith(Arquillian.class)
public class MethodLevelInterceptorTest
{
public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";

@Deployment
public static WebArchive war()
{
Expand All @@ -53,16 +52,9 @@ public static WebArchive war()
String simpleName = MethodLevelInterceptorTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

//don't create a completely empty web-archive
if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
{
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
}

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addPackage(MethodLevelInterceptorTest.class.getPackage())
.addPackage(TestPartialBeanBinding.class.getPackage())
.addPackage(PartialBean.class.getPackage())
.addPackage(CustomInterceptor.class.getPackage())
.addAsManifestResource(beansXml, "beans.xml");

return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
Expand All @@ -74,9 +66,6 @@ public static WebArchive war()
@Test
public void testMethodLevelInterceptor() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand All @@ -88,9 +77,6 @@ public void testMethodLevelInterceptor() throws Exception
@Test
public void testMethodLevelInterceptorStereotype() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand All @@ -102,9 +88,6 @@ public void testMethodLevelInterceptorStereotype() throws Exception
@Test
public void testMethodLevelInterceptorOnAbstractMethod() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

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 @@ -39,8 +39,6 @@
@RunWith(Arquillian.class)
public class ClassLevelInterceptorTest
{
public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";

@Deployment
public static WebArchive war()
{
Expand All @@ -53,13 +51,6 @@ public static WebArchive war()
String simpleName = ClassLevelInterceptorTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

//don't create a completely empty web-archive
if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
{
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
}

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addPackage(ClassLevelInterceptorTest.class.getPackage())
.addPackage(TestPartialBeanBinding.class.getPackage())
Expand All @@ -74,9 +65,6 @@ public static WebArchive war()
@Test
public void testClassLevelInterceptor() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

PartialBean partialBean = BeanProvider.getContextualReference(PartialBean.class);
CustomInterceptorState state = BeanProvider.getContextualReference(CustomInterceptorState.class);

Expand All @@ -89,9 +77,6 @@ public void testClassLevelInterceptor() throws Exception
@Test
public void testClassLevelInterceptorOnAbstractMethod() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

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 @@ -37,10 +37,8 @@
import org.junit.runner.RunWith;

@RunWith(Arquillian.class)
public class MethodLevelInterceptorTest
public class MethodLevelCacheInterceptorTest
{
public static final String CONTAINER_WELD_2_0_0 = "weld-2\\.0\\.0\\..*";

@Deployment
public static WebArchive war()
{
Expand All @@ -50,18 +48,11 @@ public static WebArchive war()
"</class></interceptors></beans>"
);

String simpleName = MethodLevelInterceptorTest.class.getSimpleName();
String simpleName = MethodLevelCacheInterceptorTest.class.getSimpleName();
String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);

//don't create a completely empty web-archive
if (CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0))
{
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive());
}

JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addPackage(MethodLevelInterceptorTest.class.getPackage())
.addPackage(MethodLevelCacheInterceptorTest.class.getPackage())
.addPackage(TestPartialBeanBinding.class.getPackage())
.addAsManifestResource(beansXml, "beans.xml");

Expand All @@ -75,17 +66,14 @@ public static WebArchive war()
@Test
public void testMethodLevelInterceptor() throws Exception
{
// this test is known to not work under weld-2.0.0.Final and weld-2.0.0.SP1
Assume.assumeTrue(!CdiContainerUnderTest.is(CONTAINER_WELD_2_0_0));

MyRepository myRepository = BeanProvider.getContextualReference(MyRepository.class);

List<String> users = myRepository.getAllUsers();

Assert.assertNotNull(users);
Assert.assertEquals(3, users.size());

Assert.assertSame(users, myRepository.getAllUsers());
Assert.assertEquals(users, myRepository.getAllUsers());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public class SimpleCacheExtension implements Extension
{
void discoverInterceptorBindings(@Observes BeforeBeanDiscovery beforeBeanDiscoveryEvent)
{
beforeBeanDiscoveryEvent.addInterceptorBinding(SimpleCache.class);
//beforeBeanDiscoveryEvent.addInterceptorBinding(SimpleCache.class);
}
}

0 comments on commit b50866e

Please sign in to comment.