yakovsh commented on code in PR #433:
URL: https://github.com/apache/commons-compress/pull/433#discussion_r1389794955


##########
src/test/java/org/apache/commons/compress/compressors/DetectCompressorTest.java:
##########
@@ -164,7 +179,43 @@ public void testDetect() throws Exception {
     }
 
     @Test
-    public void testDetection() throws Exception {
+    public void testDetectNullOrEmptyCompressorNames() throws Exception {
+        assertThrows(IllegalArgumentException.class, () -> 
CompressorStreamFactory.detect(createStreamFor("bla.txt.bz2"), (Set<String>) 
null));
+        assertThrows(IllegalArgumentException.class, () -> 
CompressorStreamFactory.detect(createStreamFor("bla.tgz"), 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

Review Comment:
   It needs two parameters, I did it with MethodSource but not sure its better 
that way



-- 
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]

Reply via email to