use of jodd.proxetta.impl.InvokeProxetta in project jodd by oblac.
the class InvReplTest method testReplacement.
@Test
public void testReplacement() throws IllegalAccessException, InstantiationException, NoSuchMethodException, IOException {
InvokeProxetta proxetta = initProxetta();
String className = One.class.getCanonicalName();
byte[] klazz = proxetta.builder(One.class).create();
//FileUtil.writeBytes("/Users/igor/OneClone.class", klazz);
FastByteArrayOutputStream fbaos = new FastByteArrayOutputStream();
// PrintStream out = System.out;
System.setOut(new PrintStream(fbaos));
One one = (One) ClassLoaderUtil.defineClass((new StringBuilder()).append(className).append(JoddProxetta.invokeProxyClassNameSuffix).toString(), klazz).newInstance();
// clone ctor calls super ctor,
assertEquals("one ctor!one ctor!", fbaos.toString());
fbaos.reset();
one.example1();
assertEquals("REPLACED VIRTUAL! jodd.proxetta.inv.Two * one!173>overriden sub", fbaos.toString());
fbaos.reset();
one.example2();
assertEquals("REPLACED STATIC! one * jodd/proxetta/inv/Two * example2 * void example2() * jodd.proxetta.inv.One * jodd.proxetta.inv.One$$Clonetou!15013static: 4", fbaos.toString());
fbaos.reset();
one.example3();
assertEquals("state = REPLACED ctor!", fbaos.toString());
fbaos.reset();
assertEquals("jodd.proxetta.inv.One$$Clonetou", one.getClass().getName());
assertTrue(one instanceof Serializable);
Annotation[] anns = one.getClass().getAnnotations();
assertEquals(3, anns.length);
Method ms = one.getClass().getMethod("example1");
anns = ms.getAnnotations();
assertEquals(1, anns.length);
}
use of jodd.proxetta.impl.InvokeProxetta in project jodd by oblac.
the class InvReplTest method testInterface.
@Test
public void testInterface() {
InvokeProxetta proxetta = initProxetta();
try {
proxetta.builder(Inter.class).newInstance();
fail();
} catch (ProxettaException ignore) {
}
}
use of jodd.proxetta.impl.InvokeProxetta in project jodd by oblac.
the class InvReplTest method testSuper.
@Test
public void testSuper() {
InvokeProxetta proxetta = initProxetta();
try {
proxetta.builder(OneWithSuper.class).define();
fail();
} catch (ProxettaException ignore) {
}
}
Aggregations