Skip to content

Commit fb6895d

Browse files
vzhiksergmerlimat
authored andcommittedJul 25, 2019
Test cleanup and simplification (apache#4799)
* Simplified assert statements in the tests. Switch to usage of static imports in tests. (Part 1) * Simplify assert statements in the tests and use the appropriate assert statements. Switch to usage of static imports in tests. Remove unused imports (Part 2)
1 parent 87c02a9 commit fb6895d

File tree

134 files changed

+1262
-1300
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+1262
-1300
lines changed
 

‎managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/EntryCacheManagerTest.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import static org.mockito.Mockito.mock;
2222
import static org.mockito.Mockito.when;
2323
import static org.testng.Assert.assertEquals;
24+
import static org.testng.Assert.assertFalse;
2425
import static org.testng.Assert.assertTrue;
2526

2627
import java.util.List;
@@ -29,8 +30,6 @@
2930
import org.apache.bookkeeper.common.util.OrderedScheduler;
3031
import org.apache.bookkeeper.mledger.Entry;
3132
import org.apache.bookkeeper.mledger.ManagedCursor;
32-
import org.apache.bookkeeper.mledger.ManagedLedger;
33-
import org.apache.bookkeeper.mledger.ManagedLedgerFactory;
3433
import org.apache.bookkeeper.mledger.ManagedLedgerFactoryConfig;
3534
import org.apache.bookkeeper.test.MockedBookKeeperTestCase;
3635
import org.testng.annotations.BeforeClass;
@@ -128,13 +127,13 @@ void doubleInsert() throws Exception {
128127
EntryCacheManager cacheManager = factory.getEntryCacheManager();
129128
EntryCache cache1 = cacheManager.getEntryCache(ml1);
130129

131-
assertEquals(cache1.insert(EntryImpl.create(1, 1, new byte[4])), true);
132-
assertEquals(cache1.insert(EntryImpl.create(1, 0, new byte[3])), true);
130+
assertTrue(cache1.insert(EntryImpl.create(1, 1, new byte[4])));
131+
assertTrue(cache1.insert(EntryImpl.create(1, 0, new byte[3])));
133132

134133
assertEquals(cache1.getSize(), 7);
135134
assertEquals(cacheManager.getSize(), 7);
136135

137-
assertEquals(cache1.insert(EntryImpl.create(1, 0, new byte[5])), false);
136+
assertFalse(cache1.insert(EntryImpl.create(1, 0, new byte[5])));
138137

139138
assertEquals(cache1.getSize(), 7);
140139
assertEquals(cacheManager.getSize(), 7);

‎managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorConcurrencyTest.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
package org.apache.bookkeeper.mledger.impl;
2020

2121
import static org.apache.bookkeeper.mledger.util.SafeRun.safeRun;
22-
import static org.testng.Assert.*;
22+
import static org.testng.Assert.assertEquals;
23+
import static org.testng.Assert.assertFalse;
24+
import static org.testng.Assert.assertNull;
2325

2426
import com.google.common.collect.Lists;
2527
import java.util.List;
@@ -126,7 +128,7 @@ public void run() {
126128

127129
counter.await();
128130

129-
assertEquals(gotException.get(), false);
131+
assertFalse(gotException.get());
130132
}
131133

132134
@Test
@@ -210,7 +212,7 @@ public void closeFailed(ManagedLedgerException exception, Object ctx) {
210212

211213
counter.await();
212214

213-
assertEquals(gotException.get(), false);
215+
assertFalse(gotException.get());
214216
assertEquals(closeFuture.get(), CLOSED);
215217
}
216218

@@ -266,7 +268,7 @@ public void testAckAndClose() throws Exception {
266268

267269
counter.await();
268270

269-
assertEquals(gotException.get(), false);
271+
assertFalse(gotException.get());
270272
}
271273

272274
@Test(timeOut = 30000)
@@ -312,7 +314,7 @@ public void testConcurrentIndividualDeletes() throws Exception {
312314

313315
counter.await();
314316

315-
assertEquals(gotException.get(), false);
317+
assertFalse(gotException.get());
316318
assertEquals(cursor.getMarkDeletedPosition(), addedEntries.get(addedEntries.size() - 1));
317319
}
318320

@@ -338,7 +340,7 @@ public void testConcurrentReadOfSameEntry() throws Exception {
338340
final CyclicBarrier barrier = new CyclicBarrier(numCursors);
339341
final CountDownLatch counter = new CountDownLatch(numCursors);
340342

341-
AtomicReference<String> result = new AtomicReference<String>();
343+
AtomicReference<String> result = new AtomicReference<>();
342344

343345
for (int i = 0; i < numCursors; i++) {
344346
final int cursorIndex = i;

0 commit comments

Comments
 (0)
Please sign in to comment.