@BeforeClass
  public static void setUpBeforeClass() throws Exception {
    Log.info(
        Log.FAC_TEST,
        "Setting up NDNNetworkObjectTestRepo, prefix {0}",
        testHelper.getClassNamespace());

    NDNHandle myhandle = NDNHandle.open();
    try {
      ns = new ContentName[NUM_LINKS];
      for (int i = 0; i < NUM_LINKS; ++i) {
        ns[i] =
            new ContentName(testHelper.getClassNamespace(), "Links", prefix + Integer.toString(i));
      }
      Arrays.fill(publisherid1, (byte) 6);
      Arrays.fill(publisherid2, (byte) 3);

      pubID1 = new PublisherID(publisherid1, PublisherType.KEY);
      pubID2 = new PublisherID(publisherid2, PublisherType.ISSUER_KEY);

      las[0] = new LinkAuthenticator(pubID1);
      las[1] = null;
      las[2] = new LinkAuthenticator(pubID2, null, null, SignedInfo.ContentType.DATA, contenthash1);
      las[3] = new LinkAuthenticator(pubID1, null, NDNTime.now(), null, contenthash1);

      for (int j = 4; j < NUM_LINKS; ++j) {
        las[j] = new LinkAuthenticator(pubID2, null, NDNTime.now(), null, null);
      }

      lrs = new Link[NUM_LINKS];
      for (int i = 0; i < lrs.length; ++i) {
        lrs[i] = new Link(ns[i], las[i]);
      }

      empty = new Collection();
      small1 = new Collection();
      small2 = new Collection();
      for (int i = 0; i < 5; ++i) {
        small1.add(lrs[i]);
        small2.add(lrs[i + 5]);
      }
      big = new Collection();
      for (int i = 0; i < NUM_LINKS; ++i) {
        big.add(lrs[i]);
      }
      Log.info(
          Log.FAC_TEST,
          "Finihed setting up NDNNetworkObjectTestRepo, prefix {0}",
          testHelper.getClassNamespace());
    } finally {
      myhandle.close();
      KeyManager.closeDefaultKeyManager();
    }
  }
  @Test
  public void testSaveToVersion() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testSaveToVersion");

    // Testing problem of disappearing versions, inability to get latest. Use simpler
    // object than a collection.
    NDNHandle lput = NDNHandle.open();
    NDNHandle lget = NDNHandle.open();
    try {
      ContentName testName =
          new ContentName(testHelper.getTestNamespace("testSaveToVersion"), stringObjName);

      NDNTime desiredVersion = NDNTime.now();

      NDNStringObject so = new NDNStringObject(testName, "First value", SaveType.REPOSITORY, lput);
      setupNamespace(testName);
      saveAndLog("SpecifiedVersion", so, desiredVersion, "Time: " + desiredVersion);
      TestUtils.checkObject(lput, so);
      Assert.assertEquals("Didn't write correct version", desiredVersion, so.getVersion());

      NDNStringObject ro = new NDNStringObject(testName, lget);
      ro.waitForData();
      Assert.assertEquals("Didn't read correct version", desiredVersion, ro.getVersion());
      ContentName versionName = ro.getVersionedName();

      saveAndLog("UpdatedVersion", so, null, "ReplacementData");
      TestUtils.checkObject(lput, so);
      updateAndLog("UpdatedData", ro, null);
      Assert.assertTrue(
          "New version " + so.getVersion() + " should be later than old version " + desiredVersion,
          (desiredVersion.before(so.getVersion())));
      Assert.assertEquals("Didn't read correct version", so.getVersion(), ro.getVersion());

      NDNStringObject ro2 = new NDNStringObject(versionName, null);
      ro2.waitForData();
      Assert.assertEquals("Didn't read correct version", desiredVersion, ro2.getVersion());
    } finally {
      lput.close();
      lget.close();
      KeyManager.closeDefaultKeyManager();
    }

    Log.info(Log.FAC_TEST, "Completed testSaveToVersion");
  }