Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change InvocationContextTest#testGetTargetMethod() to avoid using recursive interception #465

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,16 @@
@Binding1
@Priority(100)
public class Interceptor1 {
private static boolean getTargetOK = false;
private static SimpleBean target;

@AroundInvoke
public Object aroundInvoke(InvocationContext ctx) throws Exception {
SimpleBean target = (SimpleBean) ctx.getTarget();
int id1 = target.getId();
int id2 = (Integer) ctx.proceed();

if (id1 == id2) {
getTargetOK = true;
}
return id1;
// bean is not normal scoped therefore getTarget() will return contextual instance
target = (SimpleBean) ctx.getTarget();
return ctx.proceed();
}

public static boolean isGetTargetOK() {
return getTargetOK;
public static SimpleBean getTarget() {
return target;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.jboss.cdi.tck.interceptors.InterceptorsSections.INVOCATIONCONTEXT;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;

import org.jboss.arquillian.container.test.api.Deployment;
Expand Down Expand Up @@ -48,10 +49,11 @@ public static WebArchive createTestArchive() {
@SpecAssertion(section = CONSTRUCTOR_AND_METHOD_LEVEL_INT, id = "aa")
@SpecAssertion(section = INVOCATIONCONTEXT, id = "c")
public void testGetTargetMethod() {
// bean is dependent, contextual ref = contextual instance
SimpleBean instance = getContextualReference(SimpleBean.class);
instance.setId(10);
assertEquals(instance.getId(), 10);
assertTrue(Interceptor1.isGetTargetOK());
assertSame(Interceptor1.getTarget(), instance);
}

@Test
Expand Down