Skip to content

Commit

Permalink
Fix SerialDispatchQueueTest, and improve base test logging as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
skykelsey committed Mar 7, 2017
1 parent 816cf7e commit 6533243
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public void testStoppingDispatch() {
dispatchQueue.dispatchAsync(new DispatchTask() {
@Override
protected void execute() {
dispatchQueue.stop();
sleep(500);
addResult("task-1");
}
Expand All @@ -71,7 +72,6 @@ protected void execute() {
addResult("task-2");
}
});
dispatchQueue.stop();
sleep(1000); // wait for the first task to finish

assertResult("task-1"); // task-2 should not run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ protected void addResult(String str) {
}

protected void assertResult(String... expected) {
assertEquals("\nExpected: " + StringUtils.join(expected) +
"\nActual: " + StringUtils.join(result), expected.length, result.size());
// Make sure the expected and result sets contain the same number of items
if (expected.length != result.size()) {
fail(String.format("Expected: [%s], Actual: [%s]", StringUtils.join(expected), StringUtils.join(result)));
}

// Make sure the order and values are the same as well
for (int i = 0; i < expected.length; ++i) {
assertEquals("\nExpected: " + StringUtils.join(expected) +
"\nActual: " + StringUtils.join(result),
expected[i], result.get(i));
assertEquals(String.format("Expected: [%s], Actual: [%s],", StringUtils.join(expected), StringUtils.join(result)), expected[i], result.get(i));
}

result.clear();
Expand Down

0 comments on commit 6533243

Please sign in to comment.