Skip to content

Commit

Permalink
Using assertThrows.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnh5y committed Jun 1, 2022
1 parent b2385ef commit 759d3a8
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.function.ThrowingRunnable;
import org.junit.rules.TestName;
import org.junit.rules.Timeout;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -843,12 +844,8 @@ public void shouldThrowOnCleanupWhilePaused() throws InterruptedException {
streams::isPaused,
"Streams did not pause.");

try {
streams.cleanUp();
fail("Should have thrown IllegalStateException");
} catch (final IllegalStateException expected) {
assertEquals("Cannot clean up while running.", expected.getMessage());
}
assertThrows("Cannot clean up while running.", IllegalStateException.class,
streams::cleanUp);
}
}

Expand Down

0 comments on commit 759d3a8

Please sign in to comment.