public static void write(String content, File f) throws IOException { write(content.getBytes(), f); }
public static void write(String content, File f) throws IOException { write(content.getBytes(), f); }
@Test public void testDelete() throws Exception { DeleteResourceProcessor processor = new DeleteResourceProcessor(); CompilerAssert<File, File> compiler = compiler("compiler.deleteresource").with(compilerProvider).with(processor); File foo = compiler.getClassOutput().makePath(compiler.getClassOutput().getRoot(), "foo.txt"); Tools.write("foo", foo); compiler.assertCompile(); assertTrue(processor.done); boolean expected = compilerProvider == JavaCompilerProvider.ECJ; assertEquals(expected, processor.deleted); assertEquals(!expected, foo.exists()); }
@Test public void testDelete() throws Exception { DeleteResourceProcessor processor = new DeleteResourceProcessor(); CompilerAssert<File, File> compiler = compiler("compiler.deleteresource").with(compilerProvider).with(processor); File foo = compiler.getClassOutput().makePath(compiler.getClassOutput().getRoot(), "foo.txt"); Tools.write("foo", foo); compiler.assertCompile(); assertTrue(processor.done); boolean expected = compilerProvider == JavaCompilerProvider.ECJ; assertEquals(expected, processor.deleted); assertEquals(!expected, foo.exists()); }
File newtemplates = new File(templates.getParentFile().getParentFile(), templates.getName()); assertTrue(templates.renameTo(newtemplates)); Tools.write(Tools.read(pkg).replace("package metamodel.path;", "package metamodel;"), pkg);
File newtemplates = new File(templates.getParentFile().getParentFile(), templates.getName()); assertTrue(templates.renameTo(newtemplates)); Tools.write(Tools.read(pkg).replace("package metamodel.path;", "package metamodel;"), pkg);
@Test public void testChangeValue() throws Exception { CompilerAssert<File, File> helper = incrementalCompiler("metamodel.path"); helper.assertCompile(); // File a = helper.getSourcePath().getPath("metamodel", "path", "A.java"); Tools.write(Tools.read(a).replace("foo.gtmpl", "bar.gtmpl"), a); File foo = helper.getSourcePath().getPath("metamodel", "path", "templates", "foo.gtmpl"); File bar = new File(foo.getParentFile(), "bar.gtmpl"); assertTrue(foo.renameTo(bar)); // helper.assertCompile(); File ser = helper.getSourceOutput().getPath("juzu", "metamodel.ser"); ModuleMetaModel mm = (ModuleMetaModel)Tools.unserialize(MetaModelState.class, ser).metaModel; // JSON expected = json() .set("applications", json().list("values", json(). list("controllers"). set("handle", "ElementHandle.Package[qn=metamodel.path]"). list("templates", json(). set("path", "bar.gtmpl"). list("refs") ) ) ); assertEquals(expected, mm.toJSON()); }
@Test public void testChangeValue() throws Exception { CompilerAssert<File, File> helper = incrementalCompiler("metamodel.path"); helper.assertCompile(); // File a = helper.getSourcePath().getPath("metamodel", "path", "A.java"); Tools.write(Tools.read(a).replace("foo.gtmpl", "bar.gtmpl"), a); File foo = helper.getSourcePath().getPath("metamodel", "path", "templates", "foo.gtmpl"); File bar = new File(foo.getParentFile(), "bar.gtmpl"); assertTrue(foo.renameTo(bar)); // helper.assertCompile(); File ser = helper.getSourceOutput().getPath("juzu", "metamodel.ser"); ModuleMetaModel mm = (ModuleMetaModel)Tools.unserialize(MetaModelState.class, ser).metaModel; // JSON expected = json() .set("applications", json().list("values", json(). list("controllers"). set("handle", "ElementHandle.Package[qn=metamodel.path]"). list("templates", json(). set("path", "bar.gtmpl"). list("refs") ) ) ); assertEquals(expected, mm.toJSON()); }
@Test public void testRemoveAnnotation() throws Exception { CompilerAssert<File, File> helper = incrementalCompiler("metamodel.path"); helper.assertCompile(); // File a = helper.getSourcePath().getPath("metamodel", "path", "A.java"); Tools.write(Tools.read(a).replace("@Path(\"foo.gtmpl\")", ""), a); // helper.assertCompile(); File ser = helper.getSourceOutput().getPath("juzu", "metamodel.ser"); ModuleMetaModel mm = (ModuleMetaModel)Tools.unserialize(MetaModelState.class, ser).metaModel; // JSON expected = json() .set("applications", json(). list("values", json(). list("controllers"). set("handle", "ElementHandle.Package[qn=metamodel.path]"). list("templates") ) ); assertEquals(expected, mm.toJSON()); }
@Test public void testRemoveAnnotation() throws Exception { CompilerAssert<File, File> helper = incrementalCompiler("metamodel.path"); helper.assertCompile(); // File a = helper.getSourcePath().getPath("metamodel", "path", "A.java"); Tools.write(Tools.read(a).replace("@Path(\"foo.gtmpl\")", ""), a); // helper.assertCompile(); File ser = helper.getSourceOutput().getPath("juzu", "metamodel.ser"); ModuleMetaModel mm = (ModuleMetaModel)Tools.unserialize(MetaModelState.class, ser).metaModel; // JSON expected = json() .set("applications", json(). list("values", json(). list("controllers"). set("handle", "ElementHandle.Package[qn=metamodel.path]"). list("templates") ) ); assertEquals(expected, mm.toJSON()); }