use of org.apache.shiro.aop.MethodInterceptor in project shiro by apache.
the class AopAllianceMethodInterceptorAdapterTest method testInvoke.
@Test
public void testInvoke() throws Throwable {
MethodInvocation allianceInvocation = createMock(MethodInvocation.class);
MethodInterceptor mockShiroInterceptor = createMock(MethodInterceptor.class);
expect(mockShiroInterceptor.invoke(anyObject(AopAllianceMethodInvocationAdapter.class))).andAnswer(new IAnswer<Object>() {
public Object answer() throws Throwable {
return getCurrentArguments()[0];
}
});
final Object expectedValue = new Object();
expect(allianceInvocation.proceed()).andReturn(expectedValue);
replay(mockShiroInterceptor, allianceInvocation);
AopAllianceMethodInterceptorAdapter underTest = new AopAllianceMethodInterceptorAdapter(mockShiroInterceptor);
Object invocation = underTest.invoke(allianceInvocation);
Object value = ((AopAllianceMethodInvocationAdapter) invocation).proceed();
assertSame("Adapter invocation returned a different value.", expectedValue, value);
verify(mockShiroInterceptor, allianceInvocation);
}
Aggregations