File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
src/test/java/org/codehaus/plexus/archiver/jar Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 33import org .codehaus .plexus .archiver .ArchiverException ;
44
55import java .io .File ;
6+ import java .io .FileOutputStream ;
67import java .io .IOException ;
8+ import java .util .Random ;
79
810import junit .framework .TestCase ;
911
@@ -42,4 +44,32 @@ public void testNonCompressed()
4244 archiver .createArchive ();
4345 }
4446
47+ public void testVeryLargeJar ()
48+ throws IOException , ManifestException , ArchiverException
49+ {
50+ // Generate some number of random files that is likely to be
51+ // two or three times the number of available file handles
52+ File tmpDir = File .createTempFile ( "veryLargeJar" , null );
53+ tmpDir .delete ();
54+ tmpDir .mkdirs ();
55+ Random rand = new Random ();
56+ for ( int i = 0 ; i < 15000 ; i ++ )
57+ {
58+ File f = new File ( tmpDir , "file" + i );
59+ f .deleteOnExit ();
60+ FileOutputStream out = new FileOutputStream (f );
61+ byte [] data = new byte [10240 ]; // 10kb per file
62+ rand .nextBytes ( data );
63+ out .write ( data );
64+ out .flush ();
65+ out .close ();
66+ }
67+
68+ File jarFile = new File ( "target/output/veryLargeJar.jar" );
69+
70+ JarArchiver archiver = new JarArchiver ();
71+ archiver .setDestFile ( jarFile );
72+ archiver .addDirectory ( tmpDir );
73+ archiver .createArchive ();
74+ }
4575}
You can’t perform that action at this time.
0 commit comments