public static void assertFail(String name, String... expectedMessage) throws Exception { CompilerAssert<File, File> compiler = compiler(name); compiler.formalErrorReporting(); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); assertEquals(AssetMetaModelPlugin.CANNOT_PROCESS_ASSET, errors.get(0).getCode()); assertEquals(Arrays.asList(expectedMessage), errors.get(0).getArguments()); } }
@Test public void testCompile() throws Exception { CompilerAssert<?, ?> app = compiler("plugin.asset.notfound.compile"); app.formalErrorReporting(); List<CompilationError> errors = app.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(AssetMetaModelPlugin.ASSET_NOT_FOUND, error.getCode()); }
@Test public void testIncludeCircular() throws Exception { List<CompilationError> errors = compiler("plugin.template.tag.includecircular").formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(TemplateMetaModel.TEMPLATE_CYCLE, error.getCode()); assertEquals(Arrays.asList( "Path[/plugin/template/tag/includecircular/templates/index.gtmpl]", "/plugin/template/tag/includecircular/templates/index.gtmpl->/plugin/template/tag/includecircular/templates/foo.gtmpl"), error.getArguments()); }
@Test public void testAbstract() throws Exception { List<CompilationError> app = compiler("plugin.controller.abstract_").formalErrorReporting().failCompile(); assertEquals(1, app.size()); CompilationError error = app.get(0); assertEquals(ControllerMetaModel.CONTROLLER_IS_ABSTRACT, error.getCode()); assertTrue("Was expecting source to end with abstract_/A.java", error.getSource().endsWith("abstract_/A.java")); }
@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 testAbstract() throws Exception { List<CompilationError> app = compiler("plugin.controller.abstract_").formalErrorReporting().failCompile(); assertEquals(1, app.size()); CompilationError error = app.get(0); assertEquals(ControllerMetaModel.CONTROLLER_IS_ABSTRACT, error.getCode()); assertTrue("Was expecting source to end with abstract_/A.java", error.getSource().endsWith("abstract_/A.java")); }
@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 testNotFound() throws Exception { List<CompilationError> errors = compiler("plugin.template.tag.notfound").formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertTrue(error.getSource().endsWith("template/tag/notfound/A.java")); assertEquals(TemplateMetaModel.UNKNOWN_TAG, error.getCode()); assertEquals(Arrays.asList("notfound"), error.getArguments()); }
@Test public void testNotFound() throws Exception { List<CompilationError> errors = compiler("plugin.template.tag.notfound").formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertTrue(error.getSource().endsWith("template/tag/notfound/A.java")); assertEquals(TemplateMetaModel.UNKNOWN_TAG, error.getCode()); assertEquals(Arrays.asList("notfound"), error.getArguments()); }
@Test public void testNotAssignable() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.provider.notassignable"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.PROVIDER_NOT_ASSIGNABLE, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "provider", "notassignable", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testAbstractClass() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.provider.abstractclass"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.IMPLEMENTATION_NOT_ABSTRACT, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "provider", "abstractclass", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testNotAssignable() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.implementation.notassignable"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.IMPLEMENTATION_NOT_ASSIGNABLE, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "implementation", "notassignable", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testAbstractClass() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.implementation.abstractclass"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.IMPLEMENTATION_NOT_ABSTRACT, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "implementation", "abstractclass", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testNoPublicCtor() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.provider.factory.nopublicctor"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.PROVIDER_FACTORY_NO_PUBLIC_CTOR, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "provider", "factory", "nopublicctor", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testNoZeroCtor() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.provider.factory.nozeroargctor"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.PROVIDER_FACTORY_NO_ZERO_ARG_CTOR, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "provider", "factory", "nozeroargctor", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testAbstractClass() throws Exception { CompilerAssert<File, File> compiler = compiler("plugin.binding.provider.factory.abstractclass"); compiler.formalErrorReporting(true); List<CompilationError> errors = compiler.failCompile(); assertEquals(1, errors.size()); CompilationError error = errors.get(0); assertEquals(BindingMetaModelPlugin.IMPLEMENTATION_NOT_ABSTRACT, error.getCode()); File f = compiler.getSourcePath().getPath("plugin", "binding", "provider", "factory", "abstractclass", "package-info.java"); assertEquals(f, error.getSourceFile()); }
@Test public void testFail() throws Exception { CompilerAssert<File, File> ca = compiler("plugin.less.fail"); List<CompilationError> errors = ca.formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); assertEquals(LessMetaModelPlugin.COMPILATION_ERROR, errors.get(0).getCode()); File f = ca.getSourcePath().getPath("plugin", "less", "fail", "package-info.java"); assertEquals(f, errors.get(0).getSourceFile()); f = ca.getClassOutput().getPath("plugin", "less", "fail", "assets", "stylesheet.css"); assertNull(f); }
@Test public void testNotFound() throws Exception { CompilerAssert<File, File> ca = compiler("plugin.less.notfound"); List<CompilationError> errors = ca.formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); assertEquals(LessMetaModelPlugin.COMPILATION_ERROR, errors.get(0).getCode()); File f = ca.getSourcePath().getPath("plugin", "less", "notfound", "package-info.java"); assertEquals(f, errors.get(0).getSourceFile()); f = ca.getClassOutput().getPath("plugin", "less", "notfound", "assets", "stylesheet.css"); assertNull(f); }
@Test public void testFail() throws Exception { CompilerAssert<File, File> ca = compiler("plugin.less4j.fail"); List<CompilationError> errors = ca.formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); assertEquals(MetaModelPluginImpl.COMPILATION_ERROR, errors.get(0).getCode()); File f = ca.getSourcePath().getPath("plugin", "less4j", "fail", "package-info.java"); // assertEquals(f, errors.get(0).getSourceFile()); f = ca.getClassOutput().getPath("plugin", "less4j", "fail", "assets", "stylesheet.css"); assertNull(f); }
@Test public void testCannotResolve() throws Exception { CompilerAssert<File, File> ca = compiler("plugin.less4j.cannotresolve"); List<CompilationError> errors = ca.formalErrorReporting(true).failCompile(); assertEquals(1, errors.size()); assertEquals(MetaModelPluginImpl.COMPILATION_ERROR, errors.get(0).getCode()); File f = ca.getSourcePath().getPath("plugin", "less4j", "cannotresolve", "package-info.java"); // assertEquals(f, errors.get(0).getSourceFile()); f = ca.getClassOutput().getPath("plugin", "less4j", "cannotresolve", "assets", "stylesheet.css"); assertNull(f); } /*