You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/12/27 00:45:51 UTC
[commons-compress] branch master updated: Use assertThrows().
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 1d78f5b Use assertThrows().
1d78f5b is described below
commit 1d78f5bd8b1f86aaca702834086dd769bd84a50c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Dec 26 19:45:46 2021 -0500
Use assertThrows().
---
.../compress/compressors/DetectCompressorTestCase.java | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java b/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java
index bb16190..81cbefe 100644
--- a/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java
+++ b/src/test/java/org/apache/commons/compress/compressors/DetectCompressorTestCase.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
@@ -31,7 +32,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
-import org.apache.commons.compress.MemoryLimitException;
import org.apache.commons.compress.MockEvilInputStream;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.apache.commons.compress.compressors.deflate.DeflateCompressorInputStream;
@@ -119,12 +119,7 @@ public final class DetectCompressorTestCase {
assertNotNull(zstd);
assertTrue(zstd instanceof ZstdCompressorInputStream);
- try {
- factory.createCompressorInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY));
- fail("No exception thrown for an empty input stream");
- } catch (final CompressorException e) {
- // expected
- }
+ assertThrows(CompressorException.class, () -> factory.createCompressorInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)));
}
@Test
@@ -145,12 +140,7 @@ public final class DetectCompressorTestCase {
assertEquals(CompressorStreamFactory.Z, detect("COMPRESS-386"));
assertEquals(CompressorStreamFactory.LZMA, detect("COMPRESS-382"));
- try {
- CompressorStreamFactory.detect(new BufferedInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY)));
- fail("shouldn't be able to detect empty stream");
- } catch (final CompressorException e) {
- assertEquals("No Compressor found for the stream signature.", e.getMessage());
- }
+ assertThrows(CompressorException.class, () -> CompressorStreamFactory.detect(new BufferedInputStream(new ByteArrayInputStream(ByteUtils.EMPTY_BYTE_ARRAY))));
try {
CompressorStreamFactory.detect(null);