@Test
  public void tokenRevalidationTest() throws StoreException {
    // this test is valid only when the log has > 1 log segments i.e. when it can undergo compaction.
    if (isLogSegmented) {
      IndexSegment segmentOfToken = state.index.getIndexSegments().floorEntry(state.logOrder.lastKey()).getValue();
      StoreFindToken absoluteEndToken =
          new StoreFindToken(state.logOrder.lastKey(), state.sessionId, state.incarnationId, false,
              segmentOfToken.getResetKey(), segmentOfToken.getResetKeyType(), segmentOfToken.getResetKeyLifeVersion());
      absoluteEndToken.setBytesRead(state.index.getLogUsedCapacity());

      Offset firstIndexSegmentStartOffset = state.referenceIndex.firstKey();
      assertTrue("The first index segment must have an offset > 0", firstIndexSegmentStartOffset.getOffset() > 0);

      // generate an offset that does not exist.
      LogSegmentName newName = firstIndexSegmentStartOffset.getName().getNextGenerationName();
      long newOffset = firstIndexSegmentStartOffset.getOffset() + 1;

      // Generate an offset that is below the index start offset
      long offsetBeforeStart = firstIndexSegmentStartOffset.getOffset() - 1;

      Offset[] invalidOffsets =
          {new Offset(newName, newOffset), new Offset(firstIndexSegmentStartOffset.getName(), offsetBeforeStart)};
      MockId firstIdInFirstIndexSegment = state.referenceIndex.firstEntry().getValue().firstKey();

      for (Offset invalidOffset : invalidOffsets) {
        // Generate an index based token from invalidOffset
        StoreFindToken startToken =
            new StoreFindToken(firstIdInFirstIndexSegment, invalidOffset, state.sessionId, state.incarnationId, null,
                null, UNINITIALIZED_RESET_KEY_VERSION);
        doFindEntriesSinceTest(startToken, Long.MAX_VALUE, state.allKeys.keySet(), absoluteEndToken);

        // Generate a journal based token from invalidOffset (not in journal and is invalid)
        startToken = new StoreFindToken(invalidOffset, state.sessionId, state.incarnationId, false, null, null,
            UNINITIALIZED_RESET_KEY_VERSION);
        doFindEntriesSinceTest(startToken, Long.MAX_VALUE, state.allKeys.keySet(), absoluteEndToken);
      }
    }
  }
Tests the cases where tokens have to be revalidated on a call to
{@link PersistentIndex#findEntriesSince(FindToken, long)}.
@throws StoreException
ambry-store/src/test/java/com/github/ambry/store/IndexTest.java