Skip to content

Commit 53ac2f0

Browse files
committed
migrate-junit5-client-module
1 parent 4936d39 commit 53ac2f0

18 files changed

+6623
-6596
lines changed

bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperAdminTest.java

Lines changed: 669 additions & 644 deletions
Large diffs are not rendered by default.

bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperClientTestsWithBookieErrors.java

Lines changed: 304 additions & 286 deletions
Large diffs are not rendered by default.
Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,79 @@
11
/*
2-
*
3-
* Licensed to the Apache Software Foundation (ASF) under one
4-
* or more contributor license agreements. See the NOTICE file
5-
* distributed with this work for additional information
6-
* regarding copyright ownership. The ASF licenses this file
7-
* to you under the Apache License, Version 2.0 (the
8-
* "License"); you may not use this file except in compliance
9-
* with the License. You may obtain a copy of the License at
10-
*
11-
* http://www.apache.org/licenses/LICENSE-2.0
12-
*
13-
* Unless required by applicable law or agreed to in writing,
14-
* software distributed under the License is distributed on an
15-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16-
* KIND, either express or implied. See the License for the
17-
* specific language governing permissions and limitations
18-
* under the License.
19-
*
20-
*/
2+
*
3+
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE
4+
* file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file
5+
* to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
6+
* License. You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
11+
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
*
14+
*/
2115
package org.apache.bookkeeper.client;
2216

2317
import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
2418
import org.apache.bookkeeper.test.TestCallbacks.AddCallbackFuture;
2519
import org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase;
2620
import org.apache.zookeeper.ZooKeeper;
27-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
2822
import org.slf4j.Logger;
2923
import org.slf4j.LoggerFactory;
3024

3125
/**
3226
* Test the bookkeeper client while losing a ZK session.
3327
*/
3428
public class BookKeeperClientZKSessionExpiry extends BookKeeperClusterTestCase {
35-
private static final Logger LOG = LoggerFactory.getLogger(BookKeeperClientZKSessionExpiry.class);
3629

37-
public BookKeeperClientZKSessionExpiry() {
38-
super(4);
39-
}
30+
private static final Logger LOG = LoggerFactory.getLogger(BookKeeperClientZKSessionExpiry.class);
4031

41-
@Test
42-
public void testSessionLossWhileWriting() throws Exception {
32+
public BookKeeperClientZKSessionExpiry() {
33+
super(4);
34+
}
4335

44-
Thread expiryThread = new Thread() {
45-
@Override
46-
public void run() {
47-
try {
48-
while (true) {
49-
Thread.sleep(5000);
50-
long sessionId = bkc.getZkHandle().getSessionId();
51-
byte[] sessionPasswd = bkc.getZkHandle().getSessionPasswd();
36+
@Test
37+
void sessionLossWhileWriting() throws Exception {
5238

53-
try {
54-
ZooKeeperWatcherBase watcher = new ZooKeeperWatcherBase(10000, false);
55-
ZooKeeper zk = new ZooKeeper(zkUtil.getZooKeeperConnectString(), 10000,
56-
watcher, sessionId, sessionPasswd);
57-
zk.close();
58-
} catch (Exception e) {
59-
LOG.info("Error killing session", e);
60-
}
61-
}
62-
} catch (InterruptedException ie) {
63-
Thread.currentThread().interrupt();
64-
return;
65-
}
66-
}
67-
};
68-
expiryThread.start();
39+
Thread expiryThread = new Thread() {
40+
@Override
41+
public void run() {
42+
try {
43+
while (true) {
44+
Thread.sleep(5000);
45+
long sessionId = bkc.getZkHandle().getSessionId();
46+
byte[] sessionPasswd = bkc.getZkHandle().getSessionPasswd();
6947

70-
for (int i = 0; i < 3; i++) {
71-
LedgerHandle lh = bkc.createLedger(3, 3, 2, BookKeeper.DigestType.MAC, "foobar".getBytes());
72-
for (int j = 0; j < 100; j++) {
73-
lh.asyncAddEntry("foobar".getBytes(), new AddCallbackFuture(j), null);
48+
try {
49+
ZooKeeperWatcherBase watcher = new ZooKeeperWatcherBase(10000, true);
50+
ZooKeeper zk = new ZooKeeper(zkUtil.getZooKeeperConnectString(), 10000, watcher,
51+
sessionId,
52+
sessionPasswd);
53+
zk.close();
54+
} catch (Exception e) {
55+
LOG.info("Error killing session", e);
7456
}
75-
startNewBookie();
76-
killBookie(0);
57+
}
58+
} catch (InterruptedException ie) {
59+
Thread.currentThread().interrupt();
60+
return;
61+
}
62+
}
63+
};
64+
expiryThread.start();
7765

78-
lh.addEntry("lastEntry".getBytes());
66+
for (int i = 0; i < 3; i++) {
67+
LedgerHandle lh = bkc.createLedger(3, 3, 2, BookKeeper.DigestType.MAC, "foobar".getBytes());
68+
for (int j = 0; j < 100; j++) {
69+
lh.asyncAddEntry("foobar".getBytes(), new AddCallbackFuture(j), null);
70+
}
71+
startNewBookie();
72+
killBookie(0);
7973

80-
lh.close();
81-
}
74+
lh.addEntry("lastEntry".getBytes());
75+
76+
lh.close();
8277
}
78+
}
8379
}

0 commit comments

Comments
 (0)