File tree 1 file changed +30
-0
lines changed
src/test/java/org/codehaus/plexus/archiver/jar
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 3
3
import org .codehaus .plexus .archiver .ArchiverException ;
4
4
5
5
import java .io .File ;
6
+ import java .io .FileOutputStream ;
6
7
import java .io .IOException ;
8
+ import java .util .Random ;
7
9
8
10
import junit .framework .TestCase ;
9
11
@@ -42,4 +44,32 @@ public void testNonCompressed()
42
44
archiver .createArchive ();
43
45
}
44
46
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
+ }
45
75
}
You can’t perform that action at this time.
0 commit comments