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 51ec3e79 Add test API for subclasses
51ec3e79 is described below
commit 51ec3e7983626c24bbf2efd91cc7599c580e032f
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Nov 1 16:51:35 2023 -0400
Add test API for subclasses
Javadoc
---
.../apache/commons/compress/AbstractTestCase.java | 28 ++++++++++++++++------
1 file changed, 21 insertions(+), 7 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/AbstractTestCase.java
b/src/test/java/org/apache/commons/compress/AbstractTestCase.java
index 6dab9878..00971851 100644
--- a/src/test/java/org/apache/commons/compress/AbstractTestCase.java
+++ b/src/test/java/org/apache/commons/compress/AbstractTestCase.java
@@ -83,6 +83,7 @@ public abstract class AbstractTestCase {
/**
* Deletes a file or directory. For a directory, delete it and all
subdirectories.
*
+ * @param file a file or directory.
* @return whether deletion was successful
*/
public static boolean tryHardToDelete(final File file) {
@@ -93,6 +94,7 @@ public abstract class AbstractTestCase {
return true;
} catch (IOException e) {
e.printStackTrace();
+ file.deleteOnExit();
return false;
}
}
@@ -100,6 +102,7 @@ public abstract class AbstractTestCase {
/**
* Deletes a file or directory. For a directory, delete it and all
subdirectories.
*
+ * @param path a file or directory
* @return whether deletion was successful
*/
public static boolean tryHardToDelete(final Path path) {
@@ -203,15 +206,23 @@ public abstract class AbstractTestCase {
/**
* Checks if an archive contains all expected files.
*
- * @param archive
- * the archive to check
- * @param expected
- * a list with expected string file names
+ * @param archive the archive to check
+ * @param expected a list with expected string file names
* @throws Exception
*/
- protected void checkArchiveContent(final File archive, final List<String>
expected)
- throws Exception {
- try (InputStream inputStream = Files.newInputStream(archive.toPath());
+ protected void checkArchiveContent(final File archive, final List<String>
expected) throws Exception {
+ checkArchiveContent(archive.toPath(), expected);
+ }
+
+ /**
+ * Checks if an archive contains all expected files.
+ *
+ * @param archive the archive to check
+ * @param expected a list with expected string file names
+ * @throws Exception
+ */
+ protected void checkArchiveContent(final Path archive, final List<String>
expected) throws Exception {
+ try (InputStream inputStream = Files.newInputStream(archive);
ArchiveInputStream archiveInputStream =
factory.createArchiveInputStream(new BufferedInputStream(inputStream))) {
checkArchiveContent(archiveInputStream, expected);
}
@@ -321,6 +332,9 @@ public abstract class AbstractTestCase {
* Creates a temporary directory and a temporary file inside that
* directory, returns both of them (the directory is the first
* element of the two element array).
+ *
+ * @return temporary directory and file pair.
+ * @throws IOException Some I/O error.
*/
protected File[] createTempDirAndFile() throws IOException {
final File tmpDir = createTempDir();