Skip to content

Commit

Permalink
revert getCanonicalPath back to getPath in tests
Browse files Browse the repository at this point in the history
revert getCanonicalPath back to getPath in tests in commit srikanth-lingala#44. 19 occurrences in total need to be reverted
  • Loading branch information
LeeYoung624 committed Sep 10, 2019
1 parent 46a6916 commit 7cc6714
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/test/java/net/lingala/zip4j/AddFilesToZipIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void testAddFileWithDifferentFileNameSetsTheNewFileName() throws IOExcept
assertThat(zipFile.getFileHeaders()).hasSize(1);
assertThat(zipFile.getFileHeader("/data/newfile.txt")).isNotNull();
assertThat(zipFile.getFileHeader("sample_text_large.txt")).isNull();
zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());
}

@Test
Expand Down
34 changes: 17 additions & 17 deletions src/test/java/net/lingala/zip4j/ExtractZipFileIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testExtractAllStoreAndNoEncryptionExtractsSuccessfully() throws IOEx
ZipFile zipFile = new ZipFile(generatedZipFile);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -48,7 +48,7 @@ public void testExtractAllStoreAndZipStandardEncryptionExtractsSuccessfully() th
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -61,7 +61,7 @@ public void testExtractAllStoreAndAes128EncryptionExtractsSuccessfully() throws
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -74,7 +74,7 @@ public void testExtractAllStoreAndAes256EncryptionExtractsSuccessfully() throws
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -85,7 +85,7 @@ public void testExtractAllDeflateAndNoEncryptionExtractsSuccessfully() throws IO
ZipFile zipFile = new ZipFile(generatedZipFile);
zipFile.addFiles(FILES_TO_ADD);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -97,7 +97,7 @@ public void testExtractAllDeflateAndZipStandardEncryptionExtractsSuccessfully()
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -109,7 +109,7 @@ public void testExtractAllDeflateAndAes128EncryptionExtractsSuccessfully() throw
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -121,7 +121,7 @@ public void testExtractAllDeflateAndAes256EncryptionExtractsSuccessfully() throw
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFiles(FILES_TO_ADD, zipParameters);

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

ZipFileVerifier.verifyFolderContentsSameAsSourceFiles(outputFolder);
verifyNumberOfFilesInOutputFolder(outputFolder, 3);
Expand All @@ -134,7 +134,7 @@ public void testExtractFileWithFileHeaderWithAes128() throws IOException {
zipFile.addFiles(FILES_TO_ADD, zipParameters);

FileHeader fileHeader = zipFile.getFileHeader("sample_text_large.txt");
zipFile.extractFile(fileHeader, outputFolder.getCanonicalPath());
zipFile.extractFile(fileHeader, outputFolder.getPath());

File[] outputFiles = outputFolder.listFiles();
assertThat(outputFiles).hasSize(1);
Expand All @@ -148,7 +148,7 @@ public void testExtractFileWithFileHeaderWithAes128AndInDirectory() throws IOExc
zipFile.addFolder(TestUtils.getTestFileFromResources(""), zipParameters);

FileHeader fileHeader = zipFile.getFileHeader("test-files/öüäöäö/asöäööl");
zipFile.extractFile(fileHeader, outputFolder.getCanonicalPath());
zipFile.extractFile(fileHeader, outputFolder.getPath());

File outputFile = getFileWithNameFrom(outputFolder, "asöäööl");
ZipFileVerifier.verifyFileContent(TestUtils.getTestFileFromResources("öüäöäö/asöäööl"), outputFile);
Expand All @@ -162,7 +162,7 @@ public void testExtractFileWithFileHeaderWithAes256AndWithANewFileName() throws

String newFileName = "newFileName";
FileHeader fileHeader = zipFile.getFileHeader("sample_text_large.txt");
zipFile.extractFile(fileHeader, outputFolder.getCanonicalPath(), newFileName);
zipFile.extractFile(fileHeader, outputFolder.getPath(), newFileName);

File outputFile = getFileWithNameFrom(outputFolder, newFileName);
ZipFileVerifier.verifyFileContent(TestUtils.getTestFileFromResources("sample_text_large.txt"), outputFile);
Expand All @@ -185,7 +185,7 @@ public void testExtractFileWithFileNameWithZipStandardEncryption() throws IOExce
ZipFile zipFile = new ZipFile(generatedZipFile, PASSWORD);
zipFile.addFolder(TestUtils.getTestFileFromResources(""), zipParameters);

zipFile.extractFile("test-files/sample_directory/favicon.ico", outputFolder.getCanonicalPath());
zipFile.extractFile("test-files/sample_directory/favicon.ico", outputFolder.getPath());

File outputFile = getFileWithNameFrom(outputFolder, "favicon.ico");
ZipFileVerifier.verifyFileContent(TestUtils.getTestFileFromResources("sample_directory/favicon.ico"), outputFile);
Expand All @@ -198,7 +198,7 @@ public void testExtractFileWithFileNameWithZipStandardEncryptionAndNewFileName()
zipFile.addFolder(TestUtils.getTestFileFromResources(""), zipParameters);

String newFileName = "newFileName";
zipFile.extractFile("test-files/sample_directory/favicon.ico", outputFolder.getCanonicalPath(), newFileName);
zipFile.extractFile("test-files/sample_directory/favicon.ico", outputFolder.getPath(), newFileName);

File outputFile = getFileWithNameFrom(outputFolder, newFileName);
ZipFileVerifier.verifyFileContent(TestUtils.getTestFileFromResources("sample_directory/favicon.ico"), outputFile);
Expand All @@ -212,7 +212,7 @@ public void testExtractFilesThrowsExceptionForWrongPasswordForAes() throws IOExc

try {
zipFile = new ZipFile(generatedZipFile, "WRONG_PASSWORD".toCharArray());
zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());
fail("Should throw an exception");
} catch (ZipException e) {
assertThat(e).isNotNull();
Expand All @@ -228,7 +228,7 @@ public void testExtractFilesThrowsExceptionForWrongPasswordForZipStandardAndDefl

try {
zipFile = new ZipFile(generatedZipFile, "WRONG_PASSWORD".toCharArray());
zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());
fail("Should throw an exception");
} catch (ZipException e) {
assertThat(e).isNotNull();
Expand All @@ -245,7 +245,7 @@ public void testExtractFilesThrowsExceptionForWrongPasswordForZipStandardAndStor

try {
zipFile = new ZipFile(generatedZipFile, "WRONG_PASSWORD".toCharArray());
zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());
fail("Should throw an exception");
} catch (ZipException e) {
assertThat(e).isNotNull();
Expand All @@ -264,7 +264,7 @@ public void testExtractFilesForAZipMadeWithZip4jv1AndStoreCompressionWithAES() t
public void testExtractFilesForZipFileWhileWithCorruptExtraDataRecordLength() throws IOException {
ZipFile zipFile = new ZipFile(getTestArchiveFromResources("corrupt_extra_data_record_length.zip"));

zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());

assertThat(zipFile.getFileHeaders()).hasSize(44);
assertThat(Files.walk(outputFolder.toPath()).filter(Files::isRegularFile)).hasSize(44);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void verifyZipFileByExtractingAllFiles(File zipFileToExtract, char
assertThat(zipFileToExtract).exists();

ZipFile zipFile = new ZipFile(zipFileToExtract, password);
zipFile.extractAll(outputFolder.getCanonicalPath());
zipFile.extractAll(outputFolder.getPath());
assertThat(zipFile.getFileHeaders().size()).as("Number of file headers").isEqualTo(expectedNumberOfEntries);

List<File> extractedFiles = FileUtils.getFilesInDirectoryRecursive(outputFolder, true, true);
Expand Down

0 comments on commit 7cc6714

Please sign in to comment.