TimestampNavigation implements Navigation<Date> { @Override public NavigationFuture absolute(final Date offset) throws IOException { return new NavigationFuture() { @Override public LogPointer get() throws IOException { return navigate(offset.getTime(), 0, log.getSize()); } }; } TimestampNavigation(final Log log, final ByteLogAccess logAccess,
			final LogEntryReader<ByteLogAccess> reader); @Override NavigationFuture absolute(final Date offset);  }
@Test public void testTrivialCases() throws IOException { final Log log = buildLog(0, 10, 1000); final LogEntryReader<ByteLogAccess> reader = buildReader(); final TimestampNavigation nav = new TimestampNavigation(log, mockAccess, reader); DefaultPointer target = (DefaultPointer) nav.absolute(new Date(5)).get(); Assert.assertEquals(5, target.getOffset()); target = (DefaultPointer) nav.absolute(new Date(0)).get(); Assert.assertEquals(0, target.getOffset()); target = (DefaultPointer) nav.absolute(new Date(9)).get(); Assert.assertEquals(9, target.getOffset()); target = (DefaultPointer) nav.absolute(new Date()).get(); Assert.assertEquals(10, target.getOffset()); final Log log2 = buildLog(10, 10, 1000); final TimestampNavigation nav2 = new TimestampNavigation(log2, mockAccess, reader); target = (DefaultPointer) nav2.absolute(new Date(1)).get(); Assert.assertEquals(0, target.getOffset()); }
@Test public void testBigLog() throws IOException { final Log log = buildLog(0, 1000000, 10000000); final LogEntryReader<ByteLogAccess> reader = buildReader(); final TimestampNavigation nav = new TimestampNavigation(log, mockAccess, reader); final DefaultPointer target = (DefaultPointer) nav.absolute(new Date()).get(); Assert.assertEquals(log.getSize(), target.getOffset()); }