Skip to content

Commit de38885

Browse files
plamentotevmichael-o
authored andcommitted
Fix tests that fail when run twice in a row
Some XZ test cases assert if a file created by the execution of the test does not exists. Because they don't try to delete it first, they will fail if run more than once. This closes #62
1 parent e24e853 commit de38885

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/test/java/org/codehaus/plexus/archiver/tar/TarXzUnArchiverTest.java

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.codehaus.plexus.archiver.Archiver;
2121
import org.codehaus.plexus.archiver.UnArchiver;
2222
import org.codehaus.plexus.archiver.xz.XZArchiver;
23+
import org.codehaus.plexus.util.FileUtils;
2324
import static junit.framework.TestCase.assertEquals;
2425
import static junit.framework.TestCase.assertTrue;
2526
import static org.codehaus.plexus.PlexusTestCase.getTestFile;
@@ -48,6 +49,10 @@ public void testExtract()
4849
assertFalse( file2InTar.exists() );
4950

5051
File testXZFile = getTestFile( "target/output/archive.tar.xz" );
52+
if ( testXZFile.exists() )
53+
{
54+
FileUtils.fileDelete( testXZFile.getPath() );
55+
}
5156
assertFalse( testXZFile.exists() );
5257

5358
tarArchiver.addFile( getTestFile( "src/test/resources/manifests/manifest1.mf" ), fileName1 );

src/test/java/org/codehaus/plexus/archiver/xz/XzArchiverTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public void testCreateArchive()
5151
inputFiles[0] = "archiveForxz.zip";
5252

5353
File targetOutputFile = getTestFile( "target/output/archive.xz" );
54+
if ( targetOutputFile.exists() )
55+
{
56+
FileUtils.fileDelete( targetOutputFile.getPath() );
57+
}
5458
assertFalse( targetOutputFile.exists() );
5559

5660
archiver.addDirectory( getTestFile( "target/output" ), inputFiles, null );

0 commit comments

Comments
 (0)