File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
src/test/java/org/codehaus/plexus/archiver Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 3838import org .codehaus .plexus .archiver .ArchiverException ;
3939import org .codehaus .plexus .archiver .UnixStat ;
4040import org .codehaus .plexus .archiver .bzip2 .BZip2Compressor ;
41+ import org .codehaus .plexus .archiver .exceptions .EmptyArchiveException ;
4142import org .codehaus .plexus .archiver .gzip .GZipCompressor ;
4243import org .codehaus .plexus .archiver .util .ArchiveEntryUtils ;
4344import org .codehaus .plexus .archiver .util .Compressor ;
@@ -227,6 +228,22 @@ public void testCreateArchiveWithDetectedModes()
227228 }
228229 }
229230
231+ public void testCreateEmptyArchive ()
232+ throws Exception
233+ {
234+ TarArchiver archiver = getPosixTarArchiver ();
235+ archiver .setDestFile ( getTestFile ( "target/output/empty.tar" ) );
236+ try
237+ {
238+ archiver .createArchive ();
239+
240+ fail ( "Creating empty archive should throw EmptyArchiveException" );
241+ }
242+ catch ( EmptyArchiveException ignore )
243+ {
244+ }
245+ }
246+
230247 public void testUnicode () throws Exception
231248 {
232249 File tmpDir = getTestFile ( "src/test/resources/utf8" );
Original file line number Diff line number Diff line change 4848import org .codehaus .plexus .archiver .BasePlexusArchiverTest ;
4949import org .codehaus .plexus .archiver .UnArchiver ;
5050import org .codehaus .plexus .archiver .UnixStat ;
51+ import org .codehaus .plexus .archiver .exceptions .EmptyArchiveException ;
5152import org .codehaus .plexus .archiver .tar .TarArchiver ;
5253import org .codehaus .plexus .archiver .tar .TarFile ;
5354import org .codehaus .plexus .archiver .util .ArchiveEntryUtils ;
@@ -284,6 +285,22 @@ public void testCreateArchiveWithDetectedModes()
284285 }
285286 }
286287
288+ public void testCreateEmptyArchive ()
289+ throws Exception
290+ {
291+ ZipArchiver archiver = getZipArchiver ();
292+ archiver .setDestFile ( getTestFile ( "target/output/empty.zip" ) );
293+ try
294+ {
295+ archiver .createArchive ();
296+
297+ fail ( "Creating empty archive should throw EmptyArchiveException" );
298+ }
299+ catch ( EmptyArchiveException ignore )
300+ {
301+ }
302+ }
303+
287304 private ZipArchiver getZipArchiver ()
288305 {
289306 try
You can’t perform that action at this time.
0 commit comments