catch (ClassCastException e)
{
}
Object delegate = foreignType.newInstance();
CustomPrintStreamFactory enhancedFactory = (CustomPrintStreamFactory) ClassLoaderAdapterBuilder
.callingLoader(thisLoader)
.delegateLoader(dep1Loader).enhance(delegate);
Assert.assertTrue(Proxies.isForgeProxy(enhancedFactory));
PrintStream result = enhancedFactory.getPrintStream();
Assert.assertFalse(Proxies.isForgeProxy(result));
File file = File.createTempFile("furnace", "printStream");
file.deleteOnExit();
enhancedFactory.usePrintStream(new CustomPrintStream(file));
try
{
@SuppressWarnings("unused")
CustomPrintStream customResult = enhancedFactory.getCustomPrintStream();
Assert.fail("Should have received a classcast exception");
}
catch (ClassCastException e)
{
}