/**
   * Test method for
   * org.ccnx.ccn.profiles.VersioningProfile#addVersion(org.ccnx.ccn.protocol.ContentName, long).
   */
  @Test
  public void testVersionNameContentNameLong() {
    ContentName name;
    /* try with length 2 contentname */
    name = VersioningProfile.addVersion(abName, 256);
    byte[][] parts = {{97}, {98}, {-3, 1, 0}};
    if (!name.equals(new ContentName(parts))) fail("long encode version failed");

    /* check v=0 comes out 0 length */
    name = VersioningProfile.addVersion(abName, 0);
    if (!name.equals(ab0Name)) fail("long encode version=0 failed");
  }
  /**
   * Test method for
   * org.ccnx.ccn.profiles.VersioningProfile#addVersion(org.ccnx.ccn.protocol.ContentName,
   * java.sql.Timestamp).
   */
  @Test
  public void testVersionNameContentNameTimestamp() {
    /* try with length 2 contentname */
    CCNTime ts = new CCNTime(1000);
    ts.setNanos(15722656);

    ContentName name = VersioningProfile.addVersion(abName, ts);
    if (!name.equals(abvName)) fail("timestamp encode version failed");
  }
  @Test
  public void testPaddedVersions() throws Exception {
    ContentName name = ContentName.fromNative("/testme");
    long v0 = 0x80FFFF;
    byte[] b0 = {VersioningProfile.VERSION_MARKER, (byte) 0x80, (byte) 0xFF, (byte) 0xFF};

    ContentName vn0 = VersioningProfile.addVersion(name, v0);
    byte[] x0 = VersioningProfile.getLastVersionComponent(vn0);
    System.out.println("From long name   : " + vn0.toString());
    Assert.assertTrue(Arrays.areEqual(b0, x0));

    // now do it as ccntime
    CCNTime t0 = CCNTime.fromBinaryTimeAsLong(v0);
    vn0 = VersioningProfile.addVersion(name, t0);
    x0 = VersioningProfile.getLastVersionComponent(vn0);
    System.out.println("From ccntime name: " + vn0.toString());
    Assert.assertTrue(Arrays.areEqual(b0, x0));
  }
Exemple #4
0
  // need a responder with objects to pipeline
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    readHandle = CCNHandle.open();
    writeHandle = CCNHandle.open();

    ContentName namespace = testHelper.getTestNamespace("pipelineTest");
    testName = new ContentName(namespace, "PipelineSegments");
    testName = VersioningProfile.addVersion(testName);
    try {
      putSegments();
    } catch (Exception e) {
      Log.info(Log.FAC_TEST, "failed to put objects for pipeline test: " + e.getMessage());
      Assert.fail();
    }
  }
  /**
   * Test method for
   * org.ccnx.ccn.profiles.VersioningProfile#getLastVersionAsLong(org.ccnx.ccn.protocol.ContentName).
   *
   * @throws VersionMissingException
   */
  @Test
  public void testGetVersionAsLong() throws VersionMissingException {
    if (VersioningProfile.getLastVersionAsLong(abSegName) != 0x1040) fail();

    ContentName name = VersioningProfile.addVersion(abName, 1);
    ContentName n2 = ContentName.fromNative(name, "addon");

    Assert.assertTrue(VersioningProfile.getLastVersionAsLong(name) == 1);
    Assert.assertTrue(VersioningProfile.getLastVersionAsLong(n2) == 1);

    n2 = ContentName.fromNative(n2, "addon2", "addon3");
    Assert.assertTrue(VersioningProfile.getLastVersionAsLong(n2) == 1);

    try {
      VersioningProfile.getLastVersionAsLong(abName);
      fail();
    } catch (VersionMissingException e) {
      return;
    }
    fail();
  }
 /**
  * Test method for
  * org.ccnx.ccn.profiles.VersioningProfile#getLastVersionAsTimestamp(org.ccnx.ccn.protocol.ContentName).
  *
  * @throws VersionMissingException
  */
 @Test
 public void testGetVersionAsTimestamp() throws VersionMissingException {
   CCNTime ts = VersioningProfile.getLastVersionAsTimestamp(abSegName);
   ContentName name = VersioningProfile.addVersion(abName, ts);
   if (!name.equals(abvName)) fail();
 }
 /**
  * Test method for
  * org.ccnx.ccn.profiles.VersioningProfile#addVersion(org.ccnx.ccn.protocol.ContentName).
  *
  * @throws InterruptedException
  */
 @Test
 public void testVersionNameContentName() throws InterruptedException {
   ContentName name = VersioningProfile.addVersion(abName);
   Thread.sleep(10);
   if (name == VersioningProfile.addVersion(abSegName)) fail("should be different versions");
 }