public void _testSimple() throws Exception { CompilerAssert<?, ?> helper = compiler("plugin.template.simple"); Compiler compiler = helper.assertCompile(); // /* Content content = compiler.getClassOutput(FileKey.newResourceName("template.simple.templates", "index.groovy")); assertNotNull(content); assertTrue(compiler.getClassOutputKeys().size() > 0); // assertTrue(compiler.getSourceOutputKeys().size() > 1); Content content2 = compiler.getSourceOutput(FileKey.newJavaName("template.simple.templates.index", JavaFileObject.Kind.SOURCE)); assertNotNull(content2); // ClassLoader cl = new URLClassLoader(new URL[]{helper.getOutput().getURL()}, Thread.currentThread().getContextClassLoader()); // Class<?> aClass = cl.loadClass("template.simple.A"); Class<?> bClass = cl.loadClass("template.simple.templates.index"); TemplateStub template = (TemplateStub)bClass.newInstance(); StringWriter out = new StringWriter(); template.render(new TemplateRenderContext(new WriterPrinter(out))); assertEquals("hello", out.toString()); */ }
public void _testSimple() throws Exception { CompilerAssert<?, ?> helper = compiler("plugin.template.simple"); Compiler compiler = helper.assertCompile(); // /* Content content = compiler.getClassOutput(FileKey.newResourceName("template.simple.templates", "index.groovy")); assertNotNull(content); assertTrue(compiler.getClassOutputKeys().size() > 0); // assertTrue(compiler.getSourceOutputKeys().size() > 1); Content content2 = compiler.getSourceOutput(FileKey.newJavaName("template.simple.templates.index", JavaFileObject.Kind.SOURCE)); assertNotNull(content2); // ClassLoader cl = new URLClassLoader(new URL[]{helper.getOutput().getURL()}, Thread.currentThread().getContextClassLoader()); // Class<?> aClass = cl.loadClass("template.simple.A"); Class<?> bClass = cl.loadClass("template.simple.templates.index"); TemplateStub template = (TemplateStub)bClass.newInstance(); StringWriter out = new StringWriter(); template.render(new TemplateRenderContext(new WriterPrinter(out))); assertEquals("hello", out.toString()); */ }
@Test public void testControllerNotFound() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.template.controllernotfound"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(TemplateMetaModel.CONTROLLER_NOT_RESOLVED, error.getCode()); assertEquals(Arrays.asList("Foo.bar({})", "/plugin/template/controllernotfound/templates/index.gtmpl", "2", "4"), error.getArguments()); }
@Test public void testControllerNotFound() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.template.controllernotfound"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(TemplateMetaModel.CONTROLLER_NOT_RESOLVED, error.getCode()); assertEquals(Arrays.asList("Foo.bar({})", "/plugin/template/controllernotfound/templates/index.gtmpl", "2", "4"), error.getArguments()); }
@Test public void testExternal() throws Exception { CompilerAssert<File, File> simpleHelper = compiler("plugin.template.simple"); simpleHelper.assertCompile(); CompilerAssert<File, File> helper = compiler("plugin.template.external"); helper.addClassPath(simpleHelper.getClassOutput()); helper.assertCompile(); MockApplication<?> app = new MockApplication<File>( helper, di, Name.parse("plugin.template.external")); app.init(); MockClient client = app.client(); assertEquals("hello", client.render().assertStringResponse()); }
@Test public void testExternal() throws Exception { CompilerAssert<File, File> simpleHelper = compiler("plugin.template.simple"); simpleHelper.assertCompile(); CompilerAssert<File, File> helper = compiler("plugin.template.external"); helper.addClassPath(simpleHelper.getClassOutput()); helper.assertCompile(); MockApplication<?> app = new MockApplication<File>( helper, di, Name.parse("plugin.template.external")); app.init(); MockClient client = app.client(); assertEquals("hello", client.render().assertStringResponse()); }