assertEquals("foo.Two$$Proxetta", two.getClass().getName());
}
@Test
public void testJdk() throws Exception {
ProxyProxetta proxyProxetta = ProxyProxetta.withAspects(new ProxyAspect(StatCounterAdvice.class, new AllMethodsPointcut()));
proxyProxetta.setVariableClassName(false);
ProxyProxettaBuilder builder = proxyProxetta.builder();
builder.setTarget(Object.class);
try {
builder.define();
fail("Default class loader should not load java.*");
} catch (RuntimeException rex) {
// ignore
}
builder = proxyProxetta.builder();
builder.setTarget(Object.class);
builder.setTargetProxyClassName("foo.");
Object object = builder.newInstance();
assertNotNull(object);
assertEquals("foo.Object$$Proxetta", object.getClass().getName());
System.out.println("----------list");
StatCounter.counter = 0;
builder = proxyProxetta.builder(ArrayList.class, "foo.");
List list = (List) builder.newInstance();
assertNotNull(list);
assertEquals("foo.ArrayList$$Proxetta", list.getClass().getName());
assertEquals(1, StatCounter.counter);
list.add(new Integer(1));
assertTrue(StatCounter.counter == 3 || StatCounter.counter == 2);
System.out.println("----------set");
builder = proxyProxetta.builder(HashSet.class, "foo.");
Set set = (Set) builder.newInstance();
assertNotNull(set);
assertEquals("foo.HashSet$$Proxetta", set.getClass().getName());