use of org.aopalliance.intercept.MethodInvocation in project jetcache by alibaba.
the class JetCacheInterceptorTest method test1.
@Test
public void test1() throws Throwable {
final Method m = I1.class.getMethod("foo");
final C1 c = new C1();
pc.matches(m, C1.class);
final MethodInvocation mi = context.mock(MethodInvocation.class);
context.checking(new Expectations() {
{
try {
allowing(mi).getMethod();
will(Expectations.returnValue(m));
allowing(mi).getThis();
will(Expectations.returnValue(c));
allowing(mi).getArguments();
will(Expectations.returnValue(null));
oneOf(mi).proceed();
will(Expectations.returnValue(new Integer(100)));
} catch (Throwable e) {
Assert.fail();
}
}
});
interceptor.invoke(mi);
interceptor.invoke(mi);
}
use of org.aopalliance.intercept.MethodInvocation in project jetcache by alibaba.
the class JetCacheInterceptorTest method test2.
@Test
public void test2() throws Throwable {
final Method m = I2.class.getMethod("foo");
final C2 c = new C2();
pc.matches(m, C2.class);
final MethodInvocation mi = context.mock(MethodInvocation.class);
context.checking(new Expectations() {
{
try {
allowing(mi).getMethod();
will(Expectations.returnValue(m));
allowing(mi).getThis();
will(Expectations.returnValue(c));
allowing(mi).getArguments();
will(Expectations.returnValue(null));
oneOf(mi).proceed();
will(Expectations.returnValue(new Integer(100)));
oneOf(mi).proceed();
will(Expectations.returnValue(new Integer(100)));
oneOf(mi).proceed();
will(Expectations.returnValue(new Integer(100)));
} catch (Throwable e) {
Assert.fail();
}
}
});
interceptor.invoke(mi);
interceptor.invoke(mi);
CacheContext.enableCache(() -> {
try {
interceptor.invoke(mi);
interceptor.invoke(mi);
return null;
} catch (Throwable e) {
Assert.fail();
return null;
}
});
}
Aggregations