Example #1
0
  @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));
  }
Example #2
0
 /**
  * Add (or subtract if negative) #arg from the current version and return a new object. The caller
  * should understand that the value is used as an unsigned long.
  *
  * @return
  */
 public VersionNumber addAndReturn(long count) {
   long binaryTime = _version.toBinaryTimeAsLong();
   binaryTime += count;
   return new VersionNumber(CCNTime.fromBinaryTimeAsLong(binaryTime));
 }