cf.addField("_delegate", ToStringService.class);
cf.addConstructor(new Class[]{ToStringService.class}, null, "_delegate = $1;");
cf.proxyMethodsToDelegate(ToStringService.class, "_delegate", "<ToStringDelegator>");
ToStringService delegate = new ToStringService()
{
@Override
public String toString()
{
return "ACTUAL TO-STRING";
}
};
Class clazz = cf.createClass();
ToStringService proxy = (ToStringService) clazz.getConstructors()[0].newInstance(delegate);
assertEquals(proxy.toString(), "ACTUAL TO-STRING");
}