use of org.webpieces.compiler.impl.test.ForTestRouteId in project webpieces by deanhiller.
the class AnonymousByteCacheTest method testByteCodeExistsAtCorrectTime.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testByteCodeExistsAtCorrectTime() throws Exception {
Assert.assertFalse(byteCodeControllerFile.exists());
Assert.assertFalse(byteCodeEnumFile.exists());
//DO NOT CALL Classname.getClass().getName() so that we don't pre-load it from the default classloader and
//instead just tediously form the String ourselves...
String controller = getPackageFilter() + ".AnonymousController";
log.info("loading class " + controller);
Class c = compiler.loadClass(controller);
Assert.assertTrue(byteCodeControllerFile.exists());
//The enum is not compiled yet...it is on-demand compiled later...
Assert.assertFalse(byteCodeEnumFile.exists());
log.info("loaded");
Callable<ForTestRouteId> callable = (Callable<ForTestRouteId>) invokeMethod(c, "getRunnable");
ForTestRouteId value = callable.call();
log.info("test route id=" + value);
CompileConfig config = createCompileConfig();
//now create a new compileOnDemand which will use the bytecode cache...
compiler = CompileOnDemandFactory.createCompileOnDemand(config);
compiler.loadClass(controller, true);
Assert.assertTrue(byteCodeControllerFile.exists());
Assert.assertTrue(byteCodeEnumFile.exists());
}
Aggregations