yakovsh commented on code in PR #433:
URL: https://github.com/apache/commons-compress/pull/433#discussion_r1389640758
##########
src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java:
##########
@@ -164,7 +183,70 @@ public void testDetect() throws Exception {
}
@Test
- public void testDetection() throws Exception {
+ public void testDetectNullOrEmptyCompressorNames() throws Exception {
+ try (CompressorInputStream bzip2 = createStreamFor("bla.txt.bz2")) {
+ assertThrows(IllegalArgumentException.class, () -> {
+ CompressorStreamFactory.detect(bzip2, (Set<String>) null);
+ });
+ }
+
+ try (CompressorInputStream gzip = createStreamFor("bla.tgz")) {
+ assertThrows(IllegalArgumentException.class, () -> {
+ CompressorStreamFactory.detect(gzip, new HashSet<>());
+ });
+ }
+ }
+
+ @Test
+ public void testDetectLimitedByName() throws Exception {
+ assertEquals(CompressorStreamFactory.BZIP2, detect("bla.txt.bz2",
Review Comment:
Will do. Is this just for unit tests or also for the main code base?
##########
src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java:
##########
@@ -164,7 +183,70 @@ public void testDetect() throws Exception {
}
@Test
- public void testDetection() throws Exception {
+ public void testDetectNullOrEmptyCompressorNames() throws Exception {
+ try (CompressorInputStream bzip2 = createStreamFor("bla.txt.bz2")) {
+ assertThrows(IllegalArgumentException.class, () -> {
+ CompressorStreamFactory.detect(bzip2, (Set<String>) null);
+ });
+ }
+
+ try (CompressorInputStream gzip = createStreamFor("bla.tgz")) {
+ assertThrows(IllegalArgumentException.class, () -> {
+ CompressorStreamFactory.detect(gzip, new HashSet<>());
+ });
+ }
+ }
+
+ @Test
+ public void testDetectLimitedByName() throws Exception {
+ assertEquals(CompressorStreamFactory.BZIP2, detect("bla.txt.bz2",
+ Collections.singleton(CompressorStreamFactory.BZIP2)));
+ assertEquals(CompressorStreamFactory.GZIP, detect("bla.tgz",
+ Collections.singleton(CompressorStreamFactory.GZIP)));
+ assertEquals(CompressorStreamFactory.PACK200, detect("bla.pack",
+ Collections.singleton(CompressorStreamFactory.PACK200)));
+ assertEquals(CompressorStreamFactory.XZ, detect("bla.tar.xz",
+ Collections.singleton(CompressorStreamFactory.XZ)));
+ assertEquals(CompressorStreamFactory.DEFLATE,
detect("bla.tar.deflatez",
+ Collections.singleton(CompressorStreamFactory.DEFLATE)));
+ assertEquals(CompressorStreamFactory.LZ4_FRAMED, detect("bla.tar.lz4",
+ Collections.singleton(CompressorStreamFactory.LZ4_FRAMED)));
+ assertEquals(CompressorStreamFactory.LZMA, detect("bla.tar.lzma",
+ Collections.singleton(CompressorStreamFactory.LZMA)));
+ assertEquals(CompressorStreamFactory.SNAPPY_FRAMED,
detect("bla.tar.sz",
+ Collections.singleton(CompressorStreamFactory.SNAPPY_FRAMED)));
+ assertEquals(CompressorStreamFactory.Z, detect("bla.tar.Z",
+ Collections.singleton(CompressorStreamFactory.Z)));
+ assertEquals(CompressorStreamFactory.ZSTANDARD, detect("bla.tar.zst",
+ Collections.singleton(CompressorStreamFactory.ZSTANDARD)));
+ }
+
+ @Test
+ public void testDetectLimitedByNameNotFound() throws Exception {
+ assertThrows(CompressorException.class, () ->
Review Comment:
will do
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]