use of jodd.proxetta.data.Retro in project jodd by oblac.
the class ReturnTest method testWrapperWithProxyReturns.
@Test
public void testWrapperWithProxyReturns() throws Exception {
ProxyProxetta proxetta = ProxyProxetta.withAspects(new ProxyAspect(ReflectionReplacementAdvice.class, new AllMethodsPointcut()));
ProxyProxettaBuilder builder = proxetta.builder(Retro.class, ".Retro2");
// proxetta.setDebugFolder("d:\\");
Class proxyClass = builder.define();
Object proxy = proxyClass.newInstance();
Field field = proxyClass.getField("$__target$0");
Retro retro = new Retro();
retro.flag = true;
field.set(proxy, retro);
retro = (Retro) proxy;
assertNotNull(retro);
assertEquals("retro", retro.method1());
assertEquals(2, retro.method2());
assertEquals(3, retro.method3());
assertEquals(4, retro.method4());
assertEquals(5, retro.method5());
assertEquals(true, retro.method6());
assertEquals(7.7, retro.method7(), 0.005);
assertEquals(8.8, retro.method8(), 0.005);
assertEquals(9, retro.method9().length);
assertEquals('r', retro.method11());
retro.method10();
}
use of jodd.proxetta.data.Retro in project jodd by oblac.
the class ReturnTest method testNullReturns.
@Test
public void testNullReturns() throws Exception {
ProxyProxetta proxetta = ProxyProxetta.withAspects(new ProxyAspect(ReturnNullAdvice.class, new AllMethodsPointcut()));
ProxyProxettaBuilder builder = proxetta.builder(Retro.class, ".Retro3");
// proxetta.setDebugFolder("d:\\");
Class proxyClass = builder.define();
Object proxy = proxyClass.newInstance();
Retro retro = (Retro) proxy;
assertNotNull(retro);
assertNull(retro.method1());
assertEquals(0, retro.method2());
assertEquals(0, retro.method3());
assertEquals(0, retro.method4());
assertEquals(0, retro.method5());
assertEquals(false, retro.method6());
assertEquals(0, retro.method7(), 0.005);
assertEquals(0, retro.method8(), 0.005);
assertNull(retro.method9());
assertEquals(0, retro.method11());
retro.method10();
}
Aggregations