From 33091f9b1e5a9abc0927bc51a1670d9d5ba85a1c Mon Sep 17 00:00:00 2001 From: Igor Fedorenko Date: Thu, 19 Dec 2013 09:47:44 -0500 Subject: [PATCH] Use the same method for finding the basedir as our other code. Signed-off-by: Igor Fedorenko --- .../codehaus/plexus/util/xml/XmlUtilTest.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java index 6788837c..a7570a0a 100644 --- a/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java +++ b/src/test/java/org/codehaus/plexus/util/xml/XmlUtilTest.java @@ -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 @@ -60,7 +69,7 @@ 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; @@ -68,7 +77,7 @@ public void testPrettyFormatInputStreamOutputStream() 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 ); @@ -85,7 +94,7 @@ 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; @@ -93,7 +102,7 @@ public void testPrettyFormatReaderWriter() 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 ); @@ -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; @@ -140,7 +149,7 @@ 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; @@ -148,7 +157,7 @@ public void testPrettyFormatReaderWriter2() 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 ); @@ -160,5 +169,5 @@ public void testPrettyFormatReaderWriter2() IOUtil.close( reader ); IOUtil.close( writer ); } - } + } }