"content 1", new String((byte[]) r1r1.getContent()));
}
public void testSimpleCollectionRestore() throws RegistryException {
Collection c1 = registry.newCollection();
registry.put("/test/v11/c1", c1);
registry.createVersion("/test/v11/c1");
Resource r1 = registry.newResource();
r1.setContent("r1c1");
registry.put("/test/v11/c1/r1", r1);
registry.createVersion("/test/v11/c1");
Resource r2 = registry.newResource();
r2.setContent("r1c1");
registry.put("/test/v11/c1/r2", r2);
registry.createVersion("/test/v11/c1");
String[] c1Versions = registry.getVersions("/test/v11/c1");
assertEquals("/test/v11/c1 should have 3 versions.", c1Versions.length, 3);
registry.restoreVersion(c1Versions[2]);
Collection c1r1 = (Collection) registry.get("/test/v11/c1");
assertEquals("version 1 of c1 should not have any children", 0, c1r1.getChildren().length);
try {
registry.get("/test/v11/c1/r1");
fail("Version 1 of c1 should not have child r1");
} catch (RegistryException e) {}
try {
registry.get("/test/v11/c1/r2");
fail("Version 1 of c1 should not have child r2");
} catch (RegistryException e) {}
registry.restoreVersion(c1Versions[1]);
Collection c1r2 = (Collection) registry.get("/test/v11/c1");
assertEquals("version 2 of c1 should have 1 child", 1, c1r2.getChildren().length);
try {
registry.get("/test/v11/c1/r1");
} catch (RegistryException e) {
fail("Version 2 of c1 should have child r1");
}
try {
registry.get("/test/v11/c1/r2");
fail("Version 2 of c1 should not have child r2");
} catch (RegistryException e) {
}
registry.restoreVersion(c1Versions[0]);
Collection c1r3 = (Collection) registry.get("/test/v11/c1");
assertEquals("version 3 of c1 should have 2 children", 2, c1r3.getChildren().length);
try {
registry.get("/test/v11/c1/r1");
} catch (RegistryException e) {
fail("Version 3 of c1 should have child r1");