use of jodd.proxetta.pointcuts.AllTopMethodsPointcut in project jodd by oblac.
the class MethrefTest method testMethRefOnProxifiedClass.
@Test
public void testMethRefOnProxifiedClass() {
Methref<? extends Oink> m = Methref.on(Oink.class);
m.to().woink();
assertEquals("woink", m.ref());
ProxyAspect a1 = new ProxyAspect(DummyAdvice.class, new AllTopMethodsPointcut());
ProxyProxetta pp = ProxyProxetta.withAspects(a1);
Oink oink = (Oink) pp.builder(Oink.class).newInstance();
assertFalse(oink.getClass().equals(Oink.class));
m = Methref.on(oink.getClass());
m.to().woink();
assertEquals("woink", m.ref());
}
use of jodd.proxetta.pointcuts.AllTopMethodsPointcut in project jodd by oblac.
the class AdviceWithMethodTest method testCollector.
@Test
public void testCollector() throws NoSuchFieldException, IllegalAccessException {
ProxyProxetta proxetta = ProxyProxetta.withAspects(new ProxyAspect(CollectorAdvice.class, new AllTopMethodsPointcut()));
// proxetta.setDebugFolder("d:\\");
Foo foo = (Foo) proxetta.builder(Foo.class).newInstance();
Field field = foo.getClass().getDeclaredField("$__methods$0");
field.setAccessible(true);
List<String> list = (List<String>) field.get(foo);
assertNotNull(list);
assertEquals(0, list.size());
foo.m1();
assertEquals(1, list.size());
assertEquals("m1", list.get(0));
foo.m1();
assertEquals(2, list.size());
assertEquals("m1", list.get(0));
assertEquals("m1", list.get(1));
}
Aggregations