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 2019/12/25 23:55:44 UTC
[commons-compress] branch master updated: Fix broken test,
on Windows 10 at least.
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 711f58e Fix broken test, on Windows 10 at least.
711f58e is described below
commit 711f58e497bb9759fa4f34f40ab0ee9b3ef48e8a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Dec 25 18:55:40 2019 -0500
Fix broken test, on Windows 10 at least.
[INFO] Running org.apache.commons.compress.archivers.ZipTestCase
Cleaning up unclosed ZipFile for archive
C:\git\commons-compress\target\test-classes\COMPRESS-477\split_zip_created_by_zip\zip_to_compare_created_by_zip.zip
Failed to delete ArArchiveEntry.java in
C:\Users\ggregory\AppData\Local\Temp\dir8859418000064656822\commons-compress\src\main\java\org\apache\commons\compress\archivers\ar
Failed to delete ArArchiveInputStream.java in
C:\Users\ggregory\AppData\Local\Temp\dir8859418000064656822\commons-compress\src\main\java\org\apache\commons\compress\archivers\ar
Failed to delete ArArchiveOutputStream.java in
C:\Users\ggregory\AppData\Local\Temp\dir8859418000064656822\commons-compress\src\main\java\org\apache\commons\compress\archivers\ar
Failed to delete package.html in
C:\Users\ggregory\AppData\Local\Temp\dir8859418000064656822\commons-compress\src\main\java\org\apache\commons\compress\archivers\ar
Cleaning up unclosed ZipFile for archive
C:\git\commons-compress\target\test-classes\COMPRESS-477\split_zip_created_by_zip\zip_to_compare_created_by_zip.zip
Cleaning up unclosed ZipFile for archive
C:\git\commons-compress\target\test-classes\COMPRESS-477\split_zip_created_by_zip\zip_to_compare_created_by_zip.zip
[ERROR] Tests run: 24, Failures: 0, Errors: 1, Skipped: 0, Time elapsed:
4.972 s <<< FAILURE! - in
org.apache.commons.compress.archivers.ZipTestCase
[ERROR] buildSplitZipTest(org.apache.commons.compress.archivers.ZipTestCase)
Time elapsed: 3.098 s <<< ERROR!
java.lang.Error: Failed to delete
C:\Users\ggregory\AppData\Local\Temp\dir8859418000064656822\commons-compress\src\main\java\org\apache\commons\compress\archivers\ar
---
.../commons/compress/archivers/ZipTestCase.java | 45 ++++++++++++----------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
index ba5e114..30b5492 100644
--- a/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
+++ b/src/test/java/org/apache/commons/compress/archivers/ZipTestCase.java
@@ -682,28 +682,31 @@ public final class ZipTestCase extends AbstractTestCase {
createTestSplitZipSegments();
File lastFile = new File(dir, "splitZip.zip");
- SeekableByteChannel channel = ZipSplitReadOnlySeekableByteChannel.buildFromLastSplitSegment(lastFile);
- InputStream inputStream = Channels.newInputStream(channel);
- ZipArchiveInputStream splitInputStream = new ZipArchiveInputStream(inputStream, StandardCharsets.UTF_8.toString(), true, false, true);
-
- ArchiveEntry entry;
- File fileToCompare;
- InputStream inputStreamToCompare;
- int filesNum = countNonDirectories(directoryToZip);
- int filesCount = 0;
- while((entry = splitInputStream.getNextEntry()) != null) {
- if(entry.isDirectory()) {
- continue;
+ try (SeekableByteChannel channel = ZipSplitReadOnlySeekableByteChannel.buildFromLastSplitSegment(lastFile);
+ InputStream inputStream = Channels.newInputStream(channel);
+ ZipArchiveInputStream splitInputStream = new ZipArchiveInputStream(inputStream,
+ StandardCharsets.UTF_8.toString(), true, false, true)) {
+
+ ArchiveEntry entry;
+ File fileToCompare;
+ InputStream inputStreamToCompare;
+ int filesNum = countNonDirectories(directoryToZip);
+ int filesCount = 0;
+ while ((entry = splitInputStream.getNextEntry()) != null) {
+ if (entry.isDirectory()) {
+ continue;
+ }
+ // compare all files one by one
+ fileToCompare = new File(entry.getName());
+ inputStreamToCompare = new FileInputStream(fileToCompare);
+ Assert.assertTrue(
+ shaded.org.apache.commons.io.IOUtils.contentEquals(splitInputStream, inputStreamToCompare));
+ inputStreamToCompare.close();
+ filesCount++;
}
- // compare all files one by one
- fileToCompare = new File(entry.getName());
- inputStreamToCompare = new FileInputStream(fileToCompare);
- Assert.assertTrue(shaded.org.apache.commons.io.IOUtils.contentEquals(splitInputStream, inputStreamToCompare));
- inputStreamToCompare.close();
- filesCount++;
- }
- // and the number of files should equal
- assertEquals(filesCount, filesNum);
+ // and the number of files should equal
+ assertEquals(filesCount, filesNum);
+ }
}
private void testInputStreamStatistics(String fileName, Map<String, List<Long>> expectedStatistics)