@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 testTyped() throws Exception { MockApplication<?> app = application("plugin.template.typed").init(); MockClient client = app.client(); assertEquals("typed_template", client.render().assertStringResponse()); }
@Test public void testRelativePath() throws Exception { MockApplication<?> app = application("plugin.template.relativepath").init(); MockClient client = app.client(); assertEquals("relative_path_template", client.render().assertStringResponse()); }
@Test public void testTyped() throws Exception { MockApplication<?> app = application("plugin.template.typed").init(); MockClient client = app.client(); assertEquals("typed_template", client.render().assertStringResponse()); }
@Test public void testUndeclaredIOE() throws Exception { MockApplication<?> app = application("plugin.template.ioe").init(); MockClient client = app.client(); assertEquals("pass", client.render().assertStringResponse()); }
@Test public void testRelativePath() throws Exception { MockApplication<?> app = application("plugin.template.relativepath").init(); MockClient client = app.client(); assertEquals("relative_path_template", client.render().assertStringResponse()); }
@Test public void testUndeclaredIOE() throws Exception { MockApplication<?> app = application("plugin.template.ioe").init(); MockClient client = app.client(); assertEquals("pass", client.render().assertStringResponse()); }
@Test public void testMessage() throws Exception { MockApplication<?> app = application("plugin.template.message").init(); app.addMessage(Locale.ENGLISH, "the_key", "the_key_en"); MockClient client = app.client(); assertEquals("(the_key_en,)", client.render().assertStringResponse()); }
@Test public void testMessage() throws Exception { MockApplication<?> app = application("plugin.template.message").init(); app.addMessage(Locale.ENGLISH, "the_key", "the_key_en"); MockClient client = app.client(); assertEquals("(the_key_en,)", client.render().assertStringResponse()); }
@Test public void testPrecompileGroovy() throws Exception { MockApplication<File> app = application("plugin.template.simple").init(); ReadFileSystem<File> fs = app.getClasses(); File groovy = fs.getPath("plugin", "template", "simple", "templates", "index_.groovy"); assertNotNull(groovy); CompilerConfiguration config = new CompilerConfiguration(); config.setTargetDirectory(fs.getRoot()); CompilationUnit cu = new CompilationUnit(config); cu.addSource(groovy); cu.compile(); assertTrue(groovy.delete()); MockClient client = app.client(); assertEquals("hello", client.render().assertStringResponse()); } }
@Test public void testPrecompileGroovy() throws Exception { MockApplication<File> app = application("plugin.template.simple").init(); ReadFileSystem<File> fs = app.getClasses(); File groovy = fs.getPath("plugin", "template", "simple", "templates", "index_.groovy"); assertNotNull(groovy); CompilerConfiguration config = new CompilerConfiguration(); config.setTargetDirectory(fs.getRoot()); CompilationUnit cu = new CompilationUnit(config); cu.addSource(groovy); cu.compile(); assertTrue(groovy.delete()); 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()); }
@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()); }