public void testLayerHandle() throws Exception {
        NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module");
        LayerHandle handle = LayerHandle.forProject(project);
        FileObject expectedLayerXML = project.getProjectDirectory().getFileObject("src/org/example/module/resources/layer.xml");
        assertNotNull(expectedLayerXML);
        FileObject layerXML = handle.getLayerFile();
        assertNotNull("layer.xml already exists", layerXML);
        assertEquals("right layer file", expectedLayerXML, layerXML);
        FileSystem fs = handle.layer(true);
        assertEquals("initially empty", 0, fs.getRoot().getChildren().length);
        long initialSize = layerXML.getSize();
        fs.getRoot().createData("foo");
        assertEquals("not saved yet", initialSize, layerXML.getSize());
        fs = handle.layer(true);
        assertNotNull("still have in-memory mods", fs.findResource("foo"));
        fs.getRoot().createData("bar");
        handle.save();
        assertTrue("now it is saved", layerXML.getSize() > initialSize);
        String xml =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<!DOCTYPE filesystem PUBLIC \"-//NetBeans//DTD Filesystem 1.2//EN\" \"http://www.netbeans.org/dtds/filesystem-1_2.dtd\">\n" +
                "<filesystem>\n" +
                "    <file name=\"bar\"/>\n" +
                "    <file name=\"foo\"/>\n" +
                "</filesystem>\n";
        assertEquals("right contents too", xml, TestBase.slurp(layerXML));
        // XXX test that nbres: file contents work
    }
public void testLayerHandle() throws Exception {
        NbModuleProject project = TestBase.generateStandaloneModule(getWorkDir(), "module");
        LayerHandle handle = LayerHandle.forProject(project);
        FileObject expectedLayerXML = project.getProjectDirectory().getFileObject("src/org/example/module/resources/layer.xml");
        assertNotNull(expectedLayerXML);
        FileObject layerXML = handle.getLayerFile();
        assertNotNull("layer.xml already exists", layerXML);
        assertEquals("right layer file", expectedLayerXML, layerXML);
        FileSystem fs = handle.layer(true);
        assertEquals("initially empty", 0, fs.getRoot().getChildren().length);
        long initialSize = layerXML.getSize();
        fs.getRoot().createData("foo");
        assertEquals("not saved yet", initialSize, layerXML.getSize());
        fs = handle.layer(true);
        assertNotNull("still have in-memory mods", fs.findResource("foo"));
        fs.getRoot().createData("bar");
        handle.save();
        assertTrue("now it is saved", layerXML.getSize() > initialSize);
        String xml =
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<!DOCTYPE filesystem PUBLIC \"-//NetBeans//DTD Filesystem 1.2//EN\" \"http://www.netbeans.org/dtds/filesystem-1_2.dtd\">\n" +
                "<filesystem>\n" +
                "    <file name=\"bar\"/>\n" +
                "    <file name=\"foo\"/>\n" +
                "</filesystem>\n";
        assertEquals("right contents too", xml, TestBase.slurp(layerXML));
       
    }
public void testlayerhandle() throws exception { nbmoduleproject project = testbase.generatestandalonemodule(getworkdir(), "module"); layerhandle handle = layerhandle.forproject(project); fileobject expectedlayerxml = project.getprojectdirectory().getfileobject("src/org/example/module/resources/layer.xml"); assertnotnull(expectedlayerxml); fileobject layerxml = handle.getlayerfile(); assertnotnull("layer.xml already exists", layerxml); assertequals("right layer file", expectedlayerxml, layerxml); filesystem fs = handle.layer(true); assertequals("initially empty", 0, fs.getroot().getchildren().length); long initialsize = layerxml.getsize(); fs.getroot().createdata("foo"); assertequals("not saved yet", initialsize, layerxml.getsize()); fs = handle.layer(true); assertnotnull("still have in-memory mods", fs.findresource("foo")); fs.getroot().createdata("bar"); handle.save(); asserttrue("now it is saved", layerxml.getsize() > initialsize); string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<!doctype filesystem public \"-//netbeans//dtd filesystem 1.2//en\" \"http://www.netbeans.org/dtds/filesystem-1_2.dtd\">\n" + "<filesystem>\n" + " <file name=\"bar\"/>\n" + " <file name=\"foo\"/>\n" + "</filesystem>\n"; assertequals("right contents too", xml, testbase.slurp(layerxml)); }