aboutsummaryrefslogtreecommitdiff
path: root/android/guava-tests/test/com/google/common/io/CharSourceTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'android/guava-tests/test/com/google/common/io/CharSourceTest.java')
-rw-r--r--android/guava-tests/test/com/google/common/io/CharSourceTest.java23
1 files changed, 7 insertions, 16 deletions
diff --git a/android/guava-tests/test/com/google/common/io/CharSourceTest.java b/android/guava-tests/test/com/google/common/io/CharSourceTest.java
index 6cc210b56..a55ff4751 100644
--- a/android/guava-tests/test/com/google/common/io/CharSourceTest.java
+++ b/android/guava-tests/test/com/google/common/io/CharSourceTest.java
@@ -20,6 +20,7 @@ import static com.google.common.io.TestOption.CLOSE_THROWS;
import static com.google.common.io.TestOption.OPEN_THROWS;
import static com.google.common.io.TestOption.READ_THROWS;
import static com.google.common.io.TestOption.WRITE_THROWS;
+import static org.junit.Assert.assertThrows;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -180,11 +181,7 @@ public class CharSourceTest extends IoTestCase {
public void testClosesOnErrors_copyingToCharSinkThatThrows() {
for (TestOption option : EnumSet.of(OPEN_THROWS, WRITE_THROWS, CLOSE_THROWS)) {
TestCharSource okSource = new TestCharSource(STRING);
- try {
- okSource.copyTo(new TestCharSink(option));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestCharSink(option)));
// ensure reader was closed IF it was opened (depends on implementation whether or not it's
// opened at all if sink.newWriter() throws).
assertTrue(
@@ -195,21 +192,13 @@ public class CharSourceTest extends IoTestCase {
public void testClosesOnErrors_whenReadThrows() {
TestCharSource failSource = new TestCharSource(STRING, READ_THROWS);
- try {
- failSource.copyTo(new TestCharSink());
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> failSource.copyTo(new TestCharSink()));
assertTrue(failSource.wasStreamClosed());
}
public void testClosesOnErrors_copyingToWriterThatThrows() {
TestCharSource okSource = new TestCharSource(STRING);
- try {
- okSource.copyTo(new TestWriter(WRITE_THROWS));
- fail();
- } catch (IOException expected) {
- }
+ assertThrows(IOException.class, () -> okSource.copyTo(new TestWriter(WRITE_THROWS)));
assertTrue(okSource.wasStreamClosed());
}
@@ -332,7 +321,9 @@ public class CharSourceTest extends IoTestCase {
}
}
- /** @return the number of exceptions that were suppressed on the expected thrown exception */
+ /**
+ * @return the number of exceptions that were suppressed on the expected thrown exception
+ */
private static int runSuppressionFailureTest(CharSource in, CharSink out) {
try {
in.copyTo(out);