@Test public void testSerializableProxy() throws Exception { DynamicType.Loaded<Foo> loaded = instrument(Foo.class, MethodDelegation.to(SerializationCheck.class)); Foo instance = loaded.getLoaded().newInstance(); assertThat(instance.qux(), is((Object) (FOO + QUX))); }
@Test public void testBridgeMethodResolution() throws Exception { DynamicType.Loaded<Bar> loaded = instrument(Bar.class, MethodDelegation.to(GenericBaz.class)); Bar instance = loaded.getLoaded().newInstance(); assertThat(instance.qux(BAR), is(BAR + QUX)); }
@Test(expected = AbstractMethodError.class) public void testSuperCallOnAbstractMethod() throws Exception { DynamicType.Loaded<FooBarQuxBaz> loaded = instrument(FooBarQuxBaz.class, MethodDelegation.to(FooBar.class)); loaded.getLoaded().newInstance().qux(); }
@Test public void testSuperInstanceUnsafe() throws Exception { DynamicType.Loaded<Foo> loaded = instrument(Foo.class, MethodDelegation.to(QuxBaz.class)); Foo instance = loaded.getLoaded().newInstance(); assertThat(instance.qux(), is((Object) (FOO + QUX))); }