Skip to content

Commit b1787bb

Browse files
committed
Add test case for AbstractUnArchiver.extractFile
Lets make sure that we can extract ZIP archive when the maximum output size limit is set to the archive content size. Closes #117
1 parent dbef38c commit b1787bb

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/test/java/org/codehaus/plexus/archiver/zip/ZipUnArchiverTest.java

+18
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,24 @@ public void testZipOutputSizeException()
239239
assertTrue( ex.getMessage().startsWith( "Maximum output size limit reached" ) );
240240
}
241241

242+
public void testZipMaxOutputSizeEqualToExtractedFileSize()
243+
throws Exception
244+
{
245+
long extractedFileSize = 11L;
246+
String s = "target/zip-size-tests";
247+
File testZip = new File( getBasedir(), "src/test/jars/test.zip" );
248+
File outputDirectory = new File( getBasedir(), s );
249+
250+
FileUtils.deleteDirectory( outputDirectory );
251+
252+
ZipUnArchiver zu = getZipUnArchiver( testZip );
253+
zu.setMaxOutputSize( extractedFileSize );
254+
zu.extract( "", outputDirectory );
255+
256+
File extractedFile = new File( outputDirectory, "test.sh" );
257+
assertEquals( extractedFileSize, extractedFile.length() );
258+
}
259+
242260
private ZipArchiver getZipArchiver()
243261
{
244262
try

0 commit comments

Comments
 (0)