Skip to content

Commit

Permalink
#363 Removed invalid test
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-lingala committed Oct 19, 2021
1 parent de9bb5f commit 4e5e2d4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;

import static net.lingala.zip4j.util.InternalZipConstants.FILE_SEPARATOR;

Expand Down Expand Up @@ -159,21 +158,13 @@ private void checkOutputDirectoryStructure(File outputFile) throws ZipException
}

private File determineOutputFile(FileHeader fileHeader, String outputPath, String newFileName) {
String outputFileName;
String outputFileName = fileHeader.getFileName();
if (Zip4jUtil.isStringNotNullAndNotEmpty(newFileName)) {
outputFileName = newFileName;
} else {
// replace all slashes with file separator
outputFileName = fileHeader.getFileName();
}

return new File(outputPath + FILE_SEPARATOR + outputFileName);
}

private String getFileNameWithSystemFileSeparators(String fileNameToReplace) {
return fileNameToReplace.replaceAll("[/\\\\]", Matcher.quoteReplacement(FILE_SEPARATOR));
}

@Override
protected ProgressMonitor.Task getTask() {
return ProgressMonitor.Task.EXTRACT_ENTRY;
Expand Down
18 changes: 1 addition & 17 deletions src/test/java/net/lingala/zip4j/headers/HeaderReaderIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,22 +116,6 @@ public void testReadAllWithoutFileHeaderSignatureThrowsException() throws IOExce
}
}

@Test
public void testReadAllWithFileNameContainsWindowsDriveExcludesIt() throws IOException {
String fileName = "C:\\test.txt";
ZipModel actualZipModel = generateZipModel(1);
actualZipModel.getCentralDirectory().getFileHeaders().get(0).setFileName(fileName);
File headersFile = writeZipHeaders(actualZipModel);
actualZipModel.setZipFile(headersFile);

try(RandomAccessFile randomAccessFile = new RandomAccessFile(actualZipModel.getZipFile(),
RandomAccessFileMode.READ.getValue())) {
ZipModel readZipModel = headerReader.readAllHeaders(randomAccessFile, buildDefaultConfig());
FileHeader fileHeader = readZipModel.getCentralDirectory().getFileHeaders().get(0);
assertThat(fileHeader.getFileName()).isEqualTo("test.txt");
}
}

@Test
public void testReadAllWithoutFileNameWritesNull() throws IOException {
ZipModel actualZipModel = generateZipModel(1);
Expand Down Expand Up @@ -438,4 +422,4 @@ private File writeZipHeaders(ZipModel zipModel) throws IOException {
return headersFile;
}
}
}
}

0 comments on commit 4e5e2d4

Please sign in to comment.