Skip to content

Commit

Permalink
WFLY-2800 - Add test case to org.jboss.invocation.test.ChainedInterce…
Browse files Browse the repository at this point in the history
…ptorTestCase that proofs that org.jboss.invocation.InterceptorContext.proceed() is broken.
  • Loading branch information
ericvdmaarel authored and dmlloyd committed Jan 28, 2014
1 parent 260e342 commit d76e660
Showing 1 changed file with 29 additions and 0 deletions.
Expand Up @@ -84,4 +84,33 @@ public Object processInvocation(InterceptorContext context) throws Exception {
String expected = "3#4#1#2#Echo testAgain1#2#Echo testAgain";
assertEquals(expected, result);
}

/**
* What if again re-invokes a chained interceptor?
*/
@Test
public void testAgainWithChain() throws Exception {
Method method = ChainedInterceptorTestCase.class.getMethod("echo", String.class);
InterceptorContext context = new InterceptorContext();
context.setMethod(method);
context.setTarget(this);
context.setParameters(new Object[] { "testAgain" });

Interceptor again = new Interceptor() {
private int num = 2;
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
StringBuilder result = new StringBuilder();
while ((num--) > 0)
result.append(context.proceed());
return result;
}
};
Interceptor interceptor1 = Interceptors.getChainedInterceptor(createMyInterceptor("1"), createMyInterceptor("2"), Interceptors.getInvokingInterceptor());
Interceptor interceptor2 = Interceptors.getChainedInterceptor(createMyInterceptor("3"), createMyInterceptor("4"), again, interceptor1);

String result = (String) interceptor2.processInvocation(context);
String expected = "3#4#1#2#Echo testAgain1#2#Echo testAgain";
assertEquals(expected, result);
}
}

0 comments on commit d76e660

Please sign in to comment.