@Test
  public void testLinkToUnversioned() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testLinkToUnversioned");

    // test dereferencing link to unversioned data.
    CCNRepositoryWriter writer = new CCNRepositoryWriter(putHandle);
    ContentName unversionedDataName =
        testHelper.getTestChildName("testLinkToUnversioned", "UnversionedBigData");
    // generate some segmented data; doesn't version the name
    writer.newVersion(unversionedDataName, bigDataContent);

    Link uvBigDataLink =
        new Link(
            unversionedDataName,
            "big",
            new LinkAuthenticator(new PublisherID(putHandle.keyManager().getDefaultKeyID())));
    ContentObject bigDataTarget =
        uvBigDataLink.dereference(SystemConfiguration.SETTABLE_SHORT_TIMEOUT, getHandle);
    Log.info(
        Log.FAC_TEST,
        "BigData: Dereferenced link "
            + uvBigDataLink
            + ", retrieved content "
            + ((null == bigDataTarget) ? "null" : bigDataTarget.name()));
    Assert.assertNotNull(bigDataTarget);
    Assert.assertTrue(uvBigDataLink.targetName().isPrefixOf(bigDataTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(bigDataTarget.name()));

    Log.info(Log.FAC_TEST, "Completed testLinkToUnversioned");
  }
  @Test
  public void testMissingTarget() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testMissingTarget");

    Link linkToNowhere =
        new Link(testHelper.getTestChildName("testMissingTarget", "linkToNowhere"));
    ContentObject nothing = linkToNowhere.dereference(SystemConfiguration.SHORT_TIMEOUT, getHandle);
    Assert.assertNull(nothing);

    Log.info(Log.FAC_TEST, "Completed testMissingTarget");
  }
  @Test
  public void testWrongPublisher() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testWrongPublisher");

    byte[] fakePublisher = new byte[PublisherID.PUBLISHER_ID_LEN];
    PublisherID wrongPublisher = new PublisherID(new PublisherPublicKeyDigest(fakePublisher));

    Link linkToWrongPublisher = new Link(bigData, new LinkAuthenticator(wrongPublisher));
    ContentObject nothing =
        linkToWrongPublisher.dereference(SystemConfiguration.SHORT_TIMEOUT, getHandle);
    Assert.assertNull(nothing);

    Log.info(Log.FAC_TEST, "Completed testWrongPublisher");
  }
  @Test
  public void testDereference() throws Exception {
    Log.info(Log.FAC_TEST, "Starting testDereference");

    Link versionedLink = new Link(data[1].getVersionedName());

    // Should get back a segment, ideally first, of that specific version.
    ContentObject versionedTarget =
        versionedLink.dereference(SystemConfiguration.getDefaultTimeout(), putHandle);
    Log.info(
        Log.FAC_TEST,
        "Dereferenced link {0}, retrieved content {1}",
        versionedLink,
        ((null == versionedTarget) ? "null" : versionedTarget.name()));
    Assert.assertNotNull(versionedTarget);
    Assert.assertTrue(versionedLink.targetName().isPrefixOf(versionedTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(versionedTarget.name()));

    Link unversionedLink = new Link(data[1].getBaseName(), "unversioned", null);
    ContentObject unversionedTarget =
        unversionedLink.dereference(SystemConfiguration.getDefaultTimeout(), getHandle);
    Log.info(
        Log.FAC_TEST,
        "Dereferenced link {0}, retrieved content {1}",
        unversionedLink,
        ((null == unversionedTarget) ? "null" : unversionedTarget.name()));
    Assert.assertNotNull(unversionedTarget);
    Assert.assertTrue(unversionedLink.targetName().isPrefixOf(unversionedTarget.name()));
    Assert.assertTrue(
        data[data.length - 1].getVersionedName().isPrefixOf(unversionedTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(unversionedTarget.name()));

    Link bigDataLink =
        new Link(
            bigData,
            "big",
            new LinkAuthenticator(new PublisherID(putHandle.keyManager().getDefaultKeyID())));
    ContentObject bigDataTarget =
        bigDataLink.dereference(SystemConfiguration.getDefaultTimeout(), putHandle);
    Log.info(
        Log.FAC_TEST,
        "BigData: Dereferenced link "
            + bigDataLink
            + ", retrieved content "
            + ((null == bigDataTarget) ? "null" : bigDataTarget.name()));
    Assert.assertNotNull(bigDataTarget);
    Assert.assertTrue(bigDataLink.targetName().isPrefixOf(bigDataTarget.name()));
    Assert.assertTrue(SegmentationProfile.isFirstSegment(bigDataTarget.name()));

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