diff options
author | Sadaf Ebrahimi <sadafebrahimi@google.com> | 2024-01-03 17:28:59 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2024-01-03 17:28:59 +0000 |
commit | 0be00b5218b69852777cab76ff89457211904bc9 (patch) | |
tree | cbc7e4894708533a0ddc4e61da1d74e64393e0e1 /guava-tests/test/com/google/common/io/ByteSinkTest.java | |
parent | eec82bd5ace8fd2c4ba647f153c4c03e1bb41268 (diff) | |
parent | fcb68273955c94ebe12fda34018935b0c25d56dc (diff) | |
download | guava-0be00b5218b69852777cab76ff89457211904bc9.tar.gz |
Merge "Upgrade guava to v33.0.0" into main am: fcb6827395
Original change: https://android-review.googlesource.com/c/platform/external/guava/+/2894060
Change-Id: I59ee73835cab1c252c9a5e630e9b1afcd5c76417
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'guava-tests/test/com/google/common/io/ByteSinkTest.java')
-rw-r--r-- | guava-tests/test/com/google/common/io/ByteSinkTest.java | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/guava-tests/test/com/google/common/io/ByteSinkTest.java b/guava-tests/test/com/google/common/io/ByteSinkTest.java index 208a8fc5e..4ce3981c0 100644 --- a/guava-tests/test/com/google/common/io/ByteSinkTest.java +++ b/guava-tests/test/com/google/common/io/ByteSinkTest.java @@ -21,6 +21,7 @@ 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.assertArrayEquals; +import static org.junit.Assert.assertThrows; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -82,11 +83,7 @@ public class ByteSinkTest extends IoTestCase { for (TestOption option : EnumSet.of(OPEN_THROWS, READ_THROWS, CLOSE_THROWS)) { TestByteSource failSource = new TestByteSource(new byte[10], option); TestByteSink okSink = new TestByteSink(); - try { - failSource.copyTo(okSink); - fail(); - } catch (IOException expected) { - } + assertThrows(IOException.class, () -> failSource.copyTo(okSink)); // ensure stream was closed IF it was opened (depends on implementation whether or not it's // opened at all if source.newInputStream() throws). assertTrue( @@ -97,22 +94,14 @@ public class ByteSinkTest extends IoTestCase { public void testClosesOnErrors_whenWriteThrows() { TestByteSink failSink = new TestByteSink(WRITE_THROWS); - try { - new TestByteSource(new byte[10]).copyTo(failSink); - fail(); - } catch (IOException expected) { - } + assertThrows(IOException.class, () -> new TestByteSource(new byte[10]).copyTo(failSink)); assertTrue(failSink.wasStreamClosed()); } - public void testClosesOnErrors_writingFromInputStreamThatThrows() { + public void testClosesOnErrors_writingFromInputStreamThatThrows() throws IOException { TestByteSink okSink = new TestByteSink(); - try { - TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[10]), READ_THROWS); - okSink.writeFrom(in); - fail(); - } catch (IOException expected) { - } + TestInputStream in = new TestInputStream(new ByteArrayInputStream(new byte[10]), READ_THROWS); + assertThrows(IOException.class, () -> okSink.writeFrom(in)); assertTrue(okSink.wasStreamClosed()); } } |