Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
changed XmlUtilTest to create test output directory
Browse files Browse the repository at this point in the history
the test was sensitive to overall test execution order and was failing
if it happended to run before other tests that created target/test
directory.

Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
  • Loading branch information
ifedorenko committed Dec 19, 2013
1 parent 33091f9 commit 57b636d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
Expand Down Expand Up @@ -51,7 +52,19 @@ public final String getBasedir()
}
return basedir;
}


private File getTestOutputFile( String relPath )
throws IOException
{
final File file = new File( getBasedir(), relPath );
final File parentFile = file.getParentFile();
if ( !parentFile.isDirectory() && !parentFile.mkdirs() )
{
throw new IOException( "Could not create test directory " + parentFile );
}
return file;
}

/** {@inheritDoc} */
protected void setUp()
throws Exception
Expand All @@ -77,7 +90,7 @@ public void testPrettyFormatInputStreamOutputStream()
try
{
is = new FileInputStream( testDocument );
os = new FileOutputStream( new File( getBasedir(), "target/test/prettyFormatTestDocumentOutputStream.xml" ) );
os = new FileOutputStream( getTestOutputFile( "target/test/prettyFormatTestDocumentOutputStream.xml" ) );

assertNotNull( is );
assertNotNull( os );
Expand All @@ -102,7 +115,7 @@ public void testPrettyFormatReaderWriter()
try
{
reader = ReaderFactory.newXmlReader( testDocument );
writer = WriterFactory.newXmlWriter( new File( getBasedir(), "target/test/prettyFormatTestDocumentWriter.xml" ) );
writer = WriterFactory.newXmlWriter( getTestOutputFile( "target/test/prettyFormatTestDocumentWriter.xml" ) );

assertNotNull( reader );
assertNotNull( writer );
Expand Down Expand Up @@ -157,7 +170,7 @@ public void testPrettyFormatReaderWriter2()
try
{
reader = ReaderFactory.newXmlReader( testDocument );
writer = WriterFactory.newXmlWriter( new File( getBasedir(), "target/test/prettyFormatTestXdocWriter.xml" ) );
writer = WriterFactory.newXmlWriter( getTestOutputFile( "target/test/prettyFormatTestXdocWriter.xml" ) );

assertNotNull( reader );
assertNotNull( writer );
Expand Down

0 comments on commit 57b636d

Please sign in to comment.