use of org.apache.bookkeeper.client.LedgerHandle in project pulsar by yahoo.
the class EntryCacheTest method testRead.
@Test(timeOut = 5000)
void testRead() throws Exception {
LedgerHandle lh = getLedgerHandle();
when(lh.getId()).thenReturn((long) 0);
EntryCacheManager cacheManager = factory.getEntryCacheManager();
EntryCache entryCache = cacheManager.getEntryCache(ml);
byte[] data = new byte[10];
for (int i = 0; i < 10; i++) {
entryCache.insert(new EntryImpl(0, i, data));
}
final CountDownLatch counter = new CountDownLatch(1);
entryCache.asyncReadEntry(lh, 0, 9, false, new ReadEntriesCallback() {
public void readEntriesComplete(List<Entry> entries, Object ctx) {
assertEquals(entries.size(), 10);
entries.forEach(e -> e.release());
counter.countDown();
}
public void readEntriesFailed(ManagedLedgerException exception, Object ctx) {
Assert.fail("should not have failed");
}
}, null);
counter.await();
// Verify no entries were read from bookkeeper
verify(lh, never()).asyncReadEntries(anyLong(), anyLong(), any(ReadCallback.class), any());
}
Aggregations