use of org.apache.bookkeeper.client.BKException.BKDigestMatchException in project bookkeeper by apache.
the class BookKeeperApiTest method testOpenLedgerDigestUnmatched.
private void testOpenLedgerDigestUnmatched(boolean autodetection) throws Exception {
ClientConfiguration conf = new ClientConfiguration();
conf.setEnableDigestTypeAutodetection(autodetection);
mockBookKeeperGetConf(conf);
long lId;
try (WriteHandle writer = result(newCreateLedgerOp().withAckQuorumSize(1).withWriteQuorumSize(2).withEnsembleSize(3).withDigestType(DigestType.MAC).withPassword(password).execute())) {
lId = writer.getId();
assertEquals(-1L, writer.getLastAddPushed());
}
try (ReadHandle ignored = result(newOpenLedgerOp().withDigestType(DigestType.CRC32).withPassword(password).withLedgerId(lId).execute())) {
if (!autodetection) {
fail("Should fail to open read handle if digest type auto detection is disabled.");
}
} catch (BKDigestMatchException bme) {
if (autodetection) {
fail("Should not fail to open read handle if digest type auto detection is enabled.");
}
}
}
Aggregations