Index: oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/RestoreTest.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== diff --git a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/RestoreTest.java b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/RestoreTest.java --- a/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/RestoreTest.java (revision fd32acb73277dca38483d0f4a929be4a9983cd06) +++ b/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/version/RestoreTest.java (revision 036d3f8f3000b44f0f84d326c51117c7df784257) @@ -55,6 +55,126 @@ assertEquals(PropertyType.REFERENCE, def.getRequiredType()); } + + public void testSimpleRestoreCase1() throws RepositoryException{ + VersionManager vMgr = superuser.getWorkspace().getVersionManager(); + Node n = testRootNode.addNode(nodeName1, testNodeType); + n.addMixin(mixVersionable); + n.setProperty("prop", "a"); + superuser.save(); + String path = n.getPath(); + Version v = vMgr.checkpoint(path); // 1.0 + n.setProperty("prop", "b"); + superuser.save(); + vMgr.checkpoint(path); // 1.1 + n.remove(); + superuser.save(); + vMgr.restore(path, v, false); + assertTrue(superuser.nodeExists(path)); + n = superuser.getNode(path); + assertEquals("Property not restored", "a", n.getProperty("prop").getString()); + Property vhProp = n.getProperty(jcrVersionHistory); + assertEquals(PropertyType.REFERENCE, vhProp.getType()); + PropertyDefinition def = vhProp.getDefinition(); + assertEquals(PropertyType.REFERENCE, def.getRequiredType()); + + } + + + public void testSimpleRestoreWithRemoveFlagFalse() throws RepositoryException { + VersionManager vMgr = superuser.getWorkspace().getVersionManager(); + Node n1 = testRootNode.addNode("content", testNodeType); + n1.addMixin(mixVersionable); + n1.setProperty("prop", "a"); + superuser.save(); + vMgr.checkpoint(n1.getPath()); + superuser.save(); + Node n2=n1.addNode("www", testNodeType); + n2.addMixin(mixVersionable); + n2.setProperty("prop", "b"); + superuser.save(); + Node n3=n2.addNode("en", testNodeType); + n3.addMixin(mixVersionable); + n3.setProperty("prop", "c"); + superuser.save(); + Node n4=n3.addNode("home", testNodeType); + n4.addMixin(mixVersionable); + n4.setProperty("prop", "d"); + superuser.save(); + String path= n4.getPath(); + System.out.println("path:"+path); + superuser.save(); + Version v = vMgr.checkpoint(path); // 1.0 + Node n5= n3.addNode("testPages",testNodeType); + superuser.save(); + String absPath="/testroot/content1/www1/en1/home1"; + n4.remove(); + superuser.save(); + absPath=path; + superuser.save(); + vMgr.restore(absPath, v, false); + } + public void testRestoreForItemStaleExceptionWithRemoveFlagTrue() throws RepositoryException { + VersionManager vMgr = superuser.getWorkspace().getVersionManager(); + Node n1 = testRootNode.addNode("content", testNodeType); + n1.addMixin(mixVersionable); + n1.setProperty("prop", "a"); + superuser.save(); + vMgr.checkpoint(n1.getPath()); + superuser.save(); + Node n2=n1.addNode("www", testNodeType); + n2.addMixin(mixVersionable); + n2.setProperty("prop", "b"); + superuser.save(); + Node n3=n2.addNode("en", testNodeType); + n3.addMixin(mixVersionable); + n3.setProperty("prop", "c"); + superuser.save(); + Node n4=n3.addNode("home", testNodeType); + n4.addMixin(mixVersionable); + n4.setProperty("prop", "d"); + superuser.save(); + String path= n4.getPath(); + System.out.println("path:"+path); + Version v = vMgr.checkpoint(path); // 1.0 + superuser.save(); + Node n5= n4.addNode("testPages",testNodeType); + superuser.save(); + String absPath="/testroot/content/www/en/home/testHome"; + + vMgr.restore(absPath, v, true); + } + + public void testRestoreForItemExistsExceptionWithRemoveFlagFalse() throws RepositoryException { + VersionManager vMgr = superuser.getWorkspace().getVersionManager(); + Node n1 = testRootNode.addNode("content", testNodeType); + n1.addMixin(mixVersionable); + n1.setProperty("prop", "a"); + superuser.save(); + vMgr.checkpoint(n1.getPath()); + superuser.save(); + Node n2=n1.addNode("www", testNodeType); + n2.addMixin(mixVersionable); + n2.setProperty("prop", "b"); + superuser.save(); + Node n3=n2.addNode("en", testNodeType); + n3.addMixin(mixVersionable); + n3.setProperty("prop", "c"); + superuser.save(); + Node n4=n3.addNode("home", testNodeType); + n4.addMixin(mixVersionable); + n4.setProperty("prop", "d"); + superuser.save(); + String path= n4.getPath(); + System.out.println("path:"+path); + Version v = vMgr.checkpoint(path); // 1.0 + superuser.save(); + Node n5= n4.addNode("testPages",testNodeType); + superuser.save(); + String absPath="/testroot/content/www/en/home/testHome"; + vMgr.restore(absPath, v, false); + } + public void testRestoreReferenceableChild() throws RepositoryException { VersionManager vMgr = superuser.getWorkspace().getVersionManager(); Node n = testRootNode.addNode(nodeName1, "test:versionable");