Skip to content

Commit

Permalink
Add test case for AbstractUnArchiver.extractFile
Browse files Browse the repository at this point in the history
Lets make sure that we can extract ZIP archive when the
maximum output size limit is set to the archive content size.

Closes #117
  • Loading branch information
plamentotev committed Aug 23, 2019
1 parent dbef38c commit b1787bb
Showing 1 changed file with 18 additions and 0 deletions.
Expand Up @@ -239,6 +239,24 @@ public void testZipOutputSizeException()
assertTrue( ex.getMessage().startsWith( "Maximum output size limit reached" ) );
}

public void testZipMaxOutputSizeEqualToExtractedFileSize()
throws Exception
{
long extractedFileSize = 11L;
String s = "target/zip-size-tests";
File testZip = new File( getBasedir(), "src/test/jars/test.zip" );
File outputDirectory = new File( getBasedir(), s );

FileUtils.deleteDirectory( outputDirectory );

ZipUnArchiver zu = getZipUnArchiver( testZip );
zu.setMaxOutputSize( extractedFileSize );
zu.extract( "", outputDirectory );

File extractedFile = new File( outputDirectory, "test.sh" );
assertEquals( extractedFileSize, extractedFile.length() );
}

private ZipArchiver getZipArchiver()
{
try
Expand Down

0 comments on commit b1787bb

Please sign in to comment.