Skip to content

Test that EmptyArchiveException is thrown when creating archives with no files #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnixStat;
import org.codehaus.plexus.archiver.bzip2.BZip2Compressor;
import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
import org.codehaus.plexus.archiver.gzip.GZipCompressor;
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils;
import org.codehaus.plexus.archiver.util.Compressor;
Expand Down Expand Up @@ -227,6 +228,22 @@ public void testCreateArchiveWithDetectedModes()
}
}

public void testCreateEmptyArchive()
throws Exception
{
TarArchiver archiver = getPosixTarArchiver();
archiver.setDestFile( getTestFile( "target/output/empty.tar" ) );
try
{
archiver.createArchive();

fail( "Creating empty archive should throw EmptyArchiveException" );
}
catch ( EmptyArchiveException ignore )
{
}
}

public void testUnicode() throws Exception
{
File tmpDir = getTestFile( "src/test/resources/utf8" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.codehaus.plexus.archiver.BasePlexusArchiverTest;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.UnixStat;
import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
import org.codehaus.plexus.archiver.tar.TarArchiver;
import org.codehaus.plexus.archiver.tar.TarFile;
import org.codehaus.plexus.archiver.util.ArchiveEntryUtils;
Expand Down Expand Up @@ -284,6 +285,22 @@ public void testCreateArchiveWithDetectedModes()
}
}

public void testCreateEmptyArchive()
throws Exception
{
ZipArchiver archiver = getZipArchiver();
archiver.setDestFile( getTestFile( "target/output/empty.zip" ) );
try
{
archiver.createArchive();

fail( "Creating empty archive should throw EmptyArchiveException" );
}
catch ( EmptyArchiveException ignore )
{
}
}

private ZipArchiver getZipArchiver()
{
try
Expand Down