@Test public void testSaveAsGone() throws Exception { Log.info(Log.FAC_TEST, "Starting testSaveAsGone"); NDNHandle thandle = NDNHandle.open(); NDNHandle rhandle = NDNHandle.open(); NDNHandle shandle = NDNHandle.open(); try { ContentName testName = new ContentName(testHelper.getTestNamespace("testSaveAsGone"), collectionObjName); CollectionObject c0 = new CollectionObject(testName, empty, SaveType.REPOSITORY, thandle); setupNamespace(testName); NDNTime t0 = saveAsGoneAndLog("Gone", c0); Assert.assertTrue("Should be gone", c0.isGone()); ContentName goneVersionName = c0.getVersionedName(); NDNTime t1 = saveAndLog("NotGone", c0, null, small1); TestUtils.checkObject(thandle, c0); Assert.assertFalse("Should not be gone", c0.isGone()); Assert.assertTrue(t1.after(t0)); CollectionObject c1 = new CollectionObject(testName, rhandle); NDNTime t2 = waitForDataAndLog(testName.toString(), c1); Assert.assertFalse("Read back should not be gone", c1.isGone()); Assert.assertEquals(t2, t1); NDNTime t3 = updateAndLog(goneVersionName.toString(), c1, goneVersionName); Assert.assertTrue(VersioningProfile.isVersionOf(c1.getVersionedName(), testName)); Assert.assertEquals(t3, t0); Assert.assertTrue("Read back should be gone.", c1.isGone()); t0 = saveAsGoneAndLog("GoneAgain", c0); Assert.assertTrue("Should be gone", c0.isGone()); CollectionObject c2 = new CollectionObject(testName, shandle); NDNTime t4 = waitForDataAndLog(testName.toString(), c2); Assert.assertTrue( "Read back of " + c0.getVersionedName() + " should be gone, got " + c2.getVersionedName(), c2.isGone()); Assert.assertEquals(t4, t0); } finally { thandle.close(); rhandle.close(); shandle.close(); KeyManager.closeDefaultKeyManager(); } Log.info(Log.FAC_TEST, "Completed testSaveAsGone"); }
public String toString() { if (name == null) return new String("/"); ContentName n = new ContentName(name); return n.toString().replaceFirst("/", ""); }