File tree 2 files changed +34
-0
lines changed
src/test/java/org/codehaus/plexus/archiver
2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 38
38
import org .codehaus .plexus .archiver .ArchiverException ;
39
39
import org .codehaus .plexus .archiver .UnixStat ;
40
40
import org .codehaus .plexus .archiver .bzip2 .BZip2Compressor ;
41
+ import org .codehaus .plexus .archiver .exceptions .EmptyArchiveException ;
41
42
import org .codehaus .plexus .archiver .gzip .GZipCompressor ;
42
43
import org .codehaus .plexus .archiver .util .ArchiveEntryUtils ;
43
44
import org .codehaus .plexus .archiver .util .Compressor ;
@@ -227,6 +228,22 @@ public void testCreateArchiveWithDetectedModes()
227
228
}
228
229
}
229
230
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
+
230
247
public void testUnicode () throws Exception
231
248
{
232
249
File tmpDir = getTestFile ( "src/test/resources/utf8" );
Original file line number Diff line number Diff line change 48
48
import org .codehaus .plexus .archiver .BasePlexusArchiverTest ;
49
49
import org .codehaus .plexus .archiver .UnArchiver ;
50
50
import org .codehaus .plexus .archiver .UnixStat ;
51
+ import org .codehaus .plexus .archiver .exceptions .EmptyArchiveException ;
51
52
import org .codehaus .plexus .archiver .tar .TarArchiver ;
52
53
import org .codehaus .plexus .archiver .tar .TarFile ;
53
54
import org .codehaus .plexus .archiver .util .ArchiveEntryUtils ;
@@ -284,6 +285,22 @@ public void testCreateArchiveWithDetectedModes()
284
285
}
285
286
}
286
287
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
+
287
304
private ZipArchiver getZipArchiver ()
288
305
{
289
306
try
You can’t perform that action at this time.
0 commit comments