Search in sources :

Example 1 with Retro

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();
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) Field(java.lang.reflect.Field) AllMethodsPointcut(jodd.proxetta.pointcuts.AllMethodsPointcut) ProxyProxettaBuilder(jodd.proxetta.impl.ProxyProxettaBuilder) ReflectionReplacementAdvice(jodd.proxetta.data.ReflectionReplacementAdvice) Retro(jodd.proxetta.data.Retro) Test(org.junit.Test)

Example 2 with Retro

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();
}
Also used : ProxyProxetta(jodd.proxetta.impl.ProxyProxetta) AllMethodsPointcut(jodd.proxetta.pointcuts.AllMethodsPointcut) ProxyProxettaBuilder(jodd.proxetta.impl.ProxyProxettaBuilder) ReturnNullAdvice(jodd.proxetta.data.ReturnNullAdvice) Retro(jodd.proxetta.data.Retro) Test(org.junit.Test)

Aggregations

Retro (jodd.proxetta.data.Retro)2 ProxyProxetta (jodd.proxetta.impl.ProxyProxetta)2 ProxyProxettaBuilder (jodd.proxetta.impl.ProxyProxettaBuilder)2 AllMethodsPointcut (jodd.proxetta.pointcuts.AllMethodsPointcut)2 Test (org.junit.Test)2 Field (java.lang.reflect.Field)1 ReflectionReplacementAdvice (jodd.proxetta.data.ReflectionReplacementAdvice)1 ReturnNullAdvice (jodd.proxetta.data.ReturnNullAdvice)1