VersioningProfile implements CCNProfile { public static long getLastVersionAsLong(ContentName name) throws VersionMissingException { int i = findLastVersionComponent(name); if (i == -1) throw new VersionMissingException(); return getVersionComponentAsLong(name.component(i)); }  static ContentName addVersion(ContentName name, long version); @Deprecated static ContentName addVersion(ContentName name, CCNTime version); static ContentName addVersion(ContentName name); static byte [] timeToVersionComponent(CCNTime version); static String printAsVersionComponent(CCNTime version); static ContentName updateVersion(ContentName name, long version); static ContentName updateVersion(ContentName name, CCNTime version); static ContentName updateVersion(ContentName name); static int findLastVersionComponent(ContentName name); static boolean containsVersion(ContentName name); static boolean hasTerminalVersion(ContentName name); static boolean isVersionComponent(byte [] nameComponent); static boolean isBaseVersionComponent(byte [] nameComponent); static Tuple<ContentName, byte[]> cutTerminalVersion(ContentName name); static ContentName cutLastVersion(ContentName name); static long getLastVersionAsLong(ContentName name); static byte [] getLastVersionComponent(ContentName name); static long getVersionComponentAsLong(final byte [] versionComponent); static CCNTime getVersionComponentAsTimestamp(byte [] versionComponent); static CCNTime getLastVersionAsTimestamp(ContentName name); static CCNTime getLastVersionAsTimestampIfVersioned(ContentName name); static CCNTime getTerminalVersionAsTimestampIfVersioned(ContentName name); static CCNTime versionLongToTimestamp(long version); static final int baseVersion(); static int compareVersions(
			CCNTime left,
			ContentName right); static int compareVersionComponents(
			byte [] left,
			byte [] right); static boolean isVersionOf(ContentName version, ContentName parent); static boolean isLaterVersionOf(ContentName laterVersion, ContentName earlierVersion); static boolean startsWithLaterVersionOf(ContentName newName, ContentName previousVersion); static int compareTerminalVersions(ContentName laterVersion, ContentName earlierVersion); static Exclude acceptVersions(byte [] startingVersionComponent); static Interest firstBlockLatestVersionInterest(ContentName startingVersion, PublisherPublicKeyDigest publisher); static Interest latestVersionInterest(ContentName startingVersion, Integer additionalNameComponents, PublisherPublicKeyDigest publisher); static ContentObject getLatestVersion(ContentName startingVersion,
											     PublisherPublicKeyDigest publisher,
												 long timeout,
 												 ContentVerifier verifier,
												 CCNHandle handle); static ContentObject getFirstBlockOfLatestVersion(ContentName startingVersion,
															 Long startingSegmentNumber,
															 PublisherPublicKeyDigest publisher,
															 long timeout,
															 ContentVerifier verifier,
															 CCNHandle handle); static ContentObject getAnyLaterVersion(ContentName startingVersion,
											     PublisherPublicKeyDigest publisher,
												 long timeout,
 												 ContentVerifier verifier,
												 CCNHandle handle); static ContentObject getFirstBlockOfAnyLaterVersion(ContentName startingVersion,
			Long startingSegmentNumber,
			PublisherPublicKeyDigest publisher,
			long timeout,
			ContentVerifier verifier,
			CCNHandle handle); static boolean isVersionedFirstSegment(ContentName desiredName, ContentObject potentialFirstSegment, Long startingSegmentNumber); static byte[] versionComponentFromStripped(byte[] bs); static byte[] stripVersionMarker(byte[] version); static final byte VERSION_MARKER; static final byte FF; static final byte O1; static final byte OO; static final byte [] FIRST_VERSION_MARKER; static final byte [] LAST_VERSION_MARKER; static final byte [] MIN_VERSION_MARKER; static final byte [] MAX_VERSION_MARKER; static final byte [] BOTTOM_EXCLUDE_VERSION_MARKER; static final byte [] TOP_EXCLUDE_VERSION_MARKER; }
@Test public void testInvalidVersionComponentTooLong() { ContentName invalidName = null; try { invalidName = ContentName.fromURI("/name/to/test/%FD%C0%B5g%07%FEcI%FA%3AEW%12%AB%AA%82%07%18%1B%F6L%84%BD%09-%B4sy%0A%234%16"); } catch (MalformedContentNameStringException e) { Assert.fail("unable to create ContentName for test"); } try { Log.info(Log.FAC_TEST, "testing name {0}: componentBytes: {1}", invalidName, invalidName.component(3).length); long val = VersioningProfile.getLastVersionAsLong(invalidName); Assert.fail("version deemed valid. error. "+invalidName+" val = "+val); } catch (VersionMissingException e) { } }
@Test public void testInvalidVersionComponentTooShort() { ContentName invalidName = null; try { invalidName = ContentName.fromURI("/name/to/test/%FD%00%01"); } catch (MalformedContentNameStringException e) { Assert.fail("unable to create ContentName for test"); } try { Log.info(Log.FAC_TEST, "testing name {0}: componentBytes: {1}", invalidName, invalidName.component(3).length); long val = VersioningProfile.getLastVersionAsLong(invalidName); Assert.fail("version deemed valid. error. "+invalidName+" val = "+val); } catch (VersionMissingException e) { } }
@Test public void testInvalidVersionComponentValid() { ContentName validName = null; try { validName = ContentName.fromURI("/name/to/test/%FD%04%FB%DC%3BG%7D"); } catch (MalformedContentNameStringException e) { Assert.fail("unable to create ContentName for test"); } try { Log.info(Log.FAC_TEST, "testing name {0}: componentBytes: {1}", validName, validName.component(3).length); VersioningProfile.getLastVersionAsLong(validName); } catch (VersionMissingException e) { Assert.fail("version deemed invalid. error. "+validName); } }