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 2022/05/05 18:35:52 UTC
[commons-compress] branch master updated: Fix some tests.
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 102211b0 Fix some tests.
102211b0 is described below
commit 102211b0cd2076e0c05f93cc19991442f5dac16e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu May 5 14:35:47 2022 -0400
Fix some tests.
---
.../commons/compress/archivers/examples/ExpanderTest.java | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
index ca605934..b61b26be 100644
--- a/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
+++ b/src/test/java/org/apache/commons/compress/archivers/examples/ExpanderTest.java
@@ -18,6 +18,9 @@
*/
package org.apache.commons.compress.archivers.examples;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.junit.Assert.assertThrows;
+
import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
@@ -32,7 +35,6 @@ import org.apache.commons.compress.AbstractTestCase;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
-import org.apache.commons.compress.archivers.StreamingNotSupportedException;
import org.apache.commons.compress.archivers.sevenz.SevenZFile;
import org.apache.commons.compress.archivers.sevenz.SevenZOutputFile;
import org.apache.commons.compress.archivers.tar.TarFile;
@@ -44,8 +46,6 @@ import org.junit.Rule;
import org.junit.jupiter.api.Test;
import org.junit.rules.ExpectedException;
-import static java.nio.charset.StandardCharsets.*;
-
public class ExpanderTest extends AbstractTestCase {
@Rule
@@ -121,11 +121,9 @@ public class ExpanderTest extends AbstractTestCase {
@Test
public void fileCantEscapeDoubleDotPath() throws IOException, ArchiveException {
- thrown.expect(IOException.class);
- thrown.expectMessage("Expanding ../foo would create file outside of");
setupZip("../foo");
try (ZipFile f = new ZipFile(archive)) {
- new Expander().expand(f, resultDir);
+ assertThrows(IOException.class, () -> new Expander().expand(f, resultDir));
}
}
@@ -138,11 +136,9 @@ public class ExpanderTest extends AbstractTestCase {
Assume.assumeTrue(s.exists());
s.deleteOnExit();
try {
- thrown.expect(IOException.class);
- thrown.expectMessage("Expanding ../" + sibling + "/a would create file outside of");
setupZip("../" + sibling + "/a");
try (ZipFile f = new ZipFile(archive)) {
- new Expander().expand(f, resultDir);
+ assertThrows(IOException.class, () -> new Expander().expand(f, resultDir));
}
} finally {
tryHardToDelete(s);