use of org.apache.bookkeeper.test.TestCallbacks.GenericCallbackFuture in project bookkeeper by apache.
the class AbstractZkLedgerManagerTest method testReadLedgerMetadataSuccess.
@Test
public void testReadLedgerMetadataSuccess() throws Exception {
long ledgerId = System.currentTimeMillis();
String ledgerStr = String.valueOf(ledgerId);
metadata.setVersion(new LongVersion(1234L));
Stat stat = mock(Stat.class);
when(stat.getVersion()).thenReturn(1234);
when(stat.getCtime()).thenReturn(metadata.getCtime());
mockZkGetData(ledgerStr, false, KeeperException.Code.OK.intValue(), metadata.serialize(), stat);
GenericCallbackFuture<LedgerMetadata> callbackFuture = new GenericCallbackFuture<>();
ledgerManager.readLedgerMetadata(ledgerId, callbackFuture);
LedgerMetadata readMetadata = result(callbackFuture);
assertEquals(metadata, readMetadata);
verify(mockZk, times(1)).getData(eq(ledgerStr), eq(null), any(DataCallback.class), any());
}
Aggregations