horizonzy commented on code in PR #3726:
URL: https://github.com/apache/bookkeeper/pull/3726#discussion_r1110975783
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java:
##########
@@ -1127,4 +1132,87 @@ public void
testBookieAddressResolverPassedToDNSToSwitchMapping() throws Excepti
}
}
+ @DataProvider
+ public static Object[][] IllegalLedgerCreationArguments() {
+ return new Object[][] {
+ {0, 0, 0},
+ {3, 3, -1},
+ {2, 3, 1},
+ {2, 2, 3},
+ {3, 3, 0}
+ };
+ }
+ @Test
+ @UseDataProvider("IllegalLedgerCreationArguments")
+ public void testCreateLedgerWithIllegalArguments(int ensSize, int
writeQuorumSize, int ackQuorumSize) throws Exception {
+ final byte[] passwd = "testpasswd".getBytes();
+ final byte[] data = "data".getBytes();
+
+ try {
+ LedgerHandle lh = bkc.createLedger(ensSize, writeQuorumSize,
ackQuorumSize,
+ BookKeeper.DigestType.CRC32, passwd);
+ for (int i = 0; i < 10; ++i) {
Review Comment:
The dead code can be removed.
##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java:
##########
@@ -1127,4 +1132,87 @@ public void
testBookieAddressResolverPassedToDNSToSwitchMapping() throws Excepti
}
}
+ @DataProvider
+ public static Object[][] IllegalLedgerCreationArguments() {
+ return new Object[][] {
+ {0, 0, 0},
+ {3, 3, -1},
+ {2, 3, 1},
+ {2, 2, 3},
+ {3, 3, 0}
+ };
+ }
+ @Test
+ @UseDataProvider("IllegalLedgerCreationArguments")
+ public void testCreateLedgerWithIllegalArguments(int ensSize, int
writeQuorumSize, int ackQuorumSize) throws Exception {
+ final byte[] passwd = "testpasswd".getBytes();
+ final byte[] data = "data".getBytes();
+
+ try {
+ LedgerHandle lh = bkc.createLedger(ensSize, writeQuorumSize,
ackQuorumSize,
+ BookKeeper.DigestType.CRC32, passwd);
+ for (int i = 0; i < 10; ++i) {
+ lh.addEntry(data);
+ }
+ lh.close();
+ fail();
+ } catch (Exception e) {
+ assertTrue(e instanceof BKException.BKIncorrectParameterException);
+ assertEquals(e.getMessage(), "Incorrect parameter input");
+ }
+
+ try {
+ LedgerHandle lh = bkc.createLedgerAdv(ensSize, writeQuorumSize,
ackQuorumSize,
+ BookKeeper.DigestType.CRC32, passwd);
+ for (int i = 0; i < 10; ++i) {
Review Comment:
The dead code can be removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]