Skip to content

Commit 09a1e6f

Browse files
committed
remove use of System.out.println in tests
1 parent 06322db commit 09a1e6f

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
lines changed

concurrency-limits-core/src/test/java/com/netflix/concurrency/limits/limiter/AbstractPartitionedLimiterTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,23 +298,23 @@ public void testConcurrentPartitions() throws InterruptedException {
298298
executor.shutdown();
299299
executor.awaitTermination(10, TimeUnit.SECONDS);
300300

301+
StringBuilder resultSummary = new StringBuilder();
301302
for (String partition : Arrays.asList("A", "B", "C")) {
302-
System.out.println(partition + " success count: " + successCounts.get(partition).get());
303-
System.out.println(partition + " rejection count: " + rejectionCounts.get(partition).get());
304-
System.out.println(partition + " max concurrent: " + maxConcurrents.get(partition).get());
305-
306-
// remember that we borrow unused capacity, so have to ignore local limit!
307-
Assert.assertTrue("Max concurrent for " + partition + " should not exceed global limit, was: "
308-
+ maxConcurrents.get(partition).get(),
309-
maxConcurrents.get(partition).get() <= LIMIT);
310-
Assert.assertEquals("Total attempts for " + partition + " should equal success + rejections",
303+
int successCount = successCounts.get(partition).get();
304+
int rejectionCount = rejectionCounts.get(partition).get();
305+
int maxConcurrent = maxConcurrents.get(partition).get();
306+
307+
resultSummary.append(String.format("%s(success=%d,reject=%d,maxConcurrent=%d) ",
308+
partition, successCount, rejectionCount, maxConcurrent));
309+
310+
Assert.assertTrue("Max concurrent for " + partition + " should not exceed global limit. " + resultSummary,
311+
maxConcurrent <= LIMIT);
312+
Assert.assertEquals("Total attempts for " + partition + " should equal success + rejections. " + resultSummary,
311313
THREAD_COUNT * ITERATIONS,
312-
successCounts.get(partition).get() + rejectionCounts.get(partition).get());
314+
successCount + rejectionCount);
313315
}
314316

315-
// to test a global limit, we need to ensure that max inflight globally
316-
// does not exceed the total limit, we allow some wiggle room for each thread to burst 1 over
317-
Assert.assertTrue("Global max inflight should not exceed total limit, was: " + globalMaxInflight.get(),
317+
Assert.assertTrue("Global max inflight should not exceed total limit. " + resultSummary,
318318
globalMaxInflight.get() <= LIMIT + THREAD_COUNT);
319319
}
320320

concurrency-limits-core/src/test/java/com/netflix/concurrency/limits/limiter/SimpleLimiterTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,15 @@ public void testConcurrentSimple() throws InterruptedException {
140140
executor.shutdown();
141141
executor.awaitTermination(10, TimeUnit.SECONDS);
142142

143-
System.out.println("Success count: " + successCount.get());
144-
System.out.println("Rejection count: " + rejectionCount.get());
145-
System.out.println("Max concurrent: " + maxConcurrent.get());
146-
147-
Assert.assertTrue("Max concurrent should not exceed limit", maxConcurrent.get() <= LIMIT);
148-
Assert.assertEquals("Total attempts should equal success + rejections",
143+
StringBuilder resultBuilder = new StringBuilder();
144+
resultBuilder.append("Success count: ").append(successCount.get())
145+
.append(" | Rejection count: ").append(rejectionCount.get())
146+
.append(" | Max concurrent: ").append(maxConcurrent.get());
147+
String results = resultBuilder.toString();
148+
149+
Assert.assertTrue("Max concurrent should not exceed limit. " + results,
150+
maxConcurrent.get() <= LIMIT);
151+
Assert.assertEquals("Total attempts should equal success + rejections. " + results,
149152
THREAD_COUNT * ITERATIONS, successCount.get() + rejectionCount.get());
150153
}
151154

0 commit comments

Comments
 (0)