34
34
import java .util .concurrent .atomic .AtomicBoolean ;
35
35
import java .util .concurrent .atomic .AtomicInteger ;
36
36
37
- import org .awaitility .core .AssertionCondition ;
38
37
import org .junit .jupiter .api .Assertions ;
39
38
import org .junit .jupiter .api .Test ;
40
39
import org .mockito .Mockito ;
@@ -59,7 +58,7 @@ public void testPushCommittedIndex() throws Exception {
59
58
appendEntryRequest .setRemoteId (dLedgerServer0 .getMemberState ().getSelfId ());
60
59
appendEntryRequest .setBody (new byte [256 ]);
61
60
CompletableFuture <AppendEntryResponse > future = dLedgerServer0 .handleAppend (appendEntryRequest );
62
- Assertions .assertTrue ( future instanceof AppendFuture );
61
+ Assertions .assertInstanceOf ( AppendFuture . class , future );
63
62
futures .add (future );
64
63
}
65
64
Assertions .assertEquals (9 , dLedgerServer0 .getDLedgerStore ().getLedgerEndIndex ());
@@ -86,13 +85,12 @@ public void testPushNetworkOffline() throws Exception {
86
85
appendEntryRequest .setRemoteId (dLedgerServer0 .getMemberState ().getSelfId ());
87
86
appendEntryRequest .setBody (new byte [128 ]);
88
87
CompletableFuture <AppendEntryResponse > future = dLedgerServer0 .handleAppend (appendEntryRequest );
89
- Assertions .assertTrue ( future instanceof AppendFuture );
88
+ Assertions .assertInstanceOf ( AppendFuture . class , future );
90
89
futures .add (future );
91
90
}
92
91
Assertions .assertEquals (9 , dLedgerServer0 .getDLedgerStore ().getLedgerEndIndex ());
93
92
Thread .sleep (dLedgerServer0 .getDLedgerConfig ().getMaxWaitAckTimeMs () + 1000 );
94
- for (int i = 0 ; i < futures .size (); i ++) {
95
- CompletableFuture <AppendEntryResponse > future = futures .get (i );
93
+ for (CompletableFuture <AppendEntryResponse > future : futures ) {
96
94
Assertions .assertTrue (future .isDone ());
97
95
Assertions .assertEquals (DLedgerResponseCode .WAIT_QUORUM_ACK_TIMEOUT .getCode (), future .get ().getCode ());
98
96
}
@@ -104,7 +102,7 @@ public void testPushNetworkOffline() throws Exception {
104
102
appendEntryRequest .setRemoteId (dLedgerServer0 .getMemberState ().getSelfId ());
105
103
appendEntryRequest .setBody (new byte [128 ]);
106
104
CompletableFuture <AppendEntryResponse > future = dLedgerServer0 .handleAppend (appendEntryRequest );
107
- Assertions .assertTrue ( future instanceof AppendFuture );
105
+ Assertions .assertInstanceOf ( AppendFuture . class , future );
108
106
if (future .isDone ()) {
109
107
Assertions .assertEquals (DLedgerResponseCode .LEADER_PENDING_FULL .getCode (), future .get ().getCode ());
110
108
hasWait = true ;
@@ -126,12 +124,12 @@ public void testPushNetworkNotStable() throws Exception {
126
124
appendEntryRequest .setRemoteId (dLedgerServer0 .getMemberState ().getSelfId ());
127
125
appendEntryRequest .setBody (new byte [128 ]);
128
126
CompletableFuture <AppendEntryResponse > future = dLedgerServer0 .handleAppend (appendEntryRequest );
129
- Assertions .assertTrue ( future instanceof AppendFuture );
127
+ Assertions .assertInstanceOf ( AppendFuture . class , future );
130
128
future .whenComplete ((x , ex ) -> {
131
129
sendSuccess .set (true );
132
130
});
133
131
Thread .sleep (500 );
134
- Assertions .assertTrue (! sendSuccess .get ());
132
+ Assertions .assertFalse ( sendSuccess .get ());
135
133
//start server1
136
134
DLedgerServer dLedgerServer1 = launchServer (group , peers , "n1" , "n0" , DLedgerConfig .FILE );
137
135
Thread .sleep (1500 );
@@ -140,12 +138,12 @@ public void testPushNetworkNotStable() throws Exception {
140
138
dLedgerServer1 .shutdown ();
141
139
sendSuccess .set (false );
142
140
future = dLedgerServer0 .handleAppend (appendEntryRequest );
143
- Assertions .assertTrue ( future instanceof AppendFuture );
141
+ Assertions .assertInstanceOf ( AppendFuture . class , future );
144
142
future .whenComplete ((x , ex ) -> {
145
143
sendSuccess .set (true );
146
144
});
147
145
Thread .sleep (500 );
148
- Assertions .assertTrue (! sendSuccess .get ());
146
+ Assertions .assertFalse ( sendSuccess .get ());
149
147
//restart server1
150
148
dLedgerServer1 = launchServer (group , peers , "n1" , "n0" , DLedgerConfig .FILE );
151
149
Thread .sleep (1500 );
0 commit comments