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

Commit

Permalink
Use the same method for finding the basedir as our other code.
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
  • Loading branch information
ifedorenko committed Dec 19, 2013
1 parent a153249 commit 33091f9
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,17 @@
public class XmlUtilTest
extends TestCase
{
private static final File basedir = new File( new File( "" ).getAbsolutePath() );
private String basedir;

public final String getBasedir()
{
if ( null == basedir )
{
basedir = System.getProperty( "basedir", new File( "" ).getAbsolutePath() );
}
return basedir;
}

/** {@inheritDoc} */
protected void setUp()
throws Exception
Expand All @@ -60,15 +69,15 @@ protected void tearDown()
public void testPrettyFormatInputStreamOutputStream()
throws Exception
{
File testDocument = new File( basedir, "src/test/resources/testDocument.xhtml" );
File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" );
assertTrue( testDocument.exists() );

InputStream is = null;
OutputStream os = null;
try
{
is = new FileInputStream( testDocument );
os = new FileOutputStream( new File( basedir, "target/test/prettyFormatTestDocumentOutputStream.xml" ) );
os = new FileOutputStream( new File( getBasedir(), "target/test/prettyFormatTestDocumentOutputStream.xml" ) );

assertNotNull( is );
assertNotNull( os );
Expand All @@ -85,15 +94,15 @@ public void testPrettyFormatInputStreamOutputStream()
public void testPrettyFormatReaderWriter()
throws Exception
{
File testDocument = new File( basedir, "src/test/resources/testDocument.xhtml" );
File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" );
assertTrue( testDocument.exists() );

Reader reader = null;
Writer writer = null;
try
{
reader = ReaderFactory.newXmlReader( testDocument );
writer = WriterFactory.newXmlWriter( new File( basedir, "target/test/prettyFormatTestDocumentWriter.xml" ) );
writer = WriterFactory.newXmlWriter( new File( getBasedir(), "target/test/prettyFormatTestDocumentWriter.xml" ) );

assertNotNull( reader );
assertNotNull( writer );
Expand All @@ -110,7 +119,7 @@ public void testPrettyFormatReaderWriter()
public void testPrettyFormatString()
throws Exception
{
File testDocument = new File( basedir, "src/test/resources/testDocument.xhtml" );
File testDocument = new File( getBasedir(), "src/test/resources/testDocument.xhtml" );
assertTrue( testDocument.exists() );

Reader reader = null;
Expand Down Expand Up @@ -140,15 +149,15 @@ public void testPrettyFormatString()
public void testPrettyFormatReaderWriter2()
throws Exception
{
File testDocument = new File( basedir, "src/test/resources/test.xdoc.xhtml" );
File testDocument = new File( getBasedir(), "src/test/resources/test.xdoc.xhtml" );
assertTrue( testDocument.exists() );

Reader reader = null;
Writer writer = null;
try
{
reader = ReaderFactory.newXmlReader( testDocument );
writer = WriterFactory.newXmlWriter( new File( basedir, "target/test/prettyFormatTestXdocWriter.xml" ) );
writer = WriterFactory.newXmlWriter( new File( getBasedir(), "target/test/prettyFormatTestXdocWriter.xml" ) );

assertNotNull( reader );
assertNotNull( writer );
Expand All @@ -160,5 +169,5 @@ public void testPrettyFormatReaderWriter2()
IOUtil.close( reader );
IOUtil.close( writer );
}
}
}
}

0 comments on commit 33091f9

Please sign in to comment.