diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java index 72c04c6ad..407f07ec2 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java @@ -19,6 +19,8 @@ package org.apache.tools.ant.taskdefs.optional.junit; import java.io.File; import java.io.FileReader; +import java.io.InputStream; +import java.net.URL; import org.apache.tools.ant.BuildFileTest; import org.apache.tools.ant.util.FileUtils; @@ -110,15 +112,26 @@ public class JUnitReportTest extends BuildFileTest { // Bugzilla Report 38477 public void testSpecialSignsInSrcPath() throws Exception { executeTarget("testSpecialSignsInSrcPath"); - if (! new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html").exists()) { - fail("No index.html present. Not generated?"); - } + File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); } public void testSpecialSignsInHtmlPath() throws Exception { executeTarget("testSpecialSignsInHtmlPath"); - if (! new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html# $%§&-!report/index.html").exists()) { - fail("No index.html present. Not generated?"); - } + File reportFile = new File(System.getProperty("root"), "src/etc/testcases/taskdefs/optional/junitreport/test/html# $%§&-!report/index.html"); + // tests one the file object + assertTrue("No index.html present. Not generated?", reportFile.exists() ); + assertTrue("Cant read the report file.", reportFile.canRead() ); + assertTrue("File shouldnt be empty.", reportFile.length() > 0 ); + // conversion to URL via FileUtils like in XMLResultAggregator, not as suggested in the bug report + URL reportUrl = new URL( FileUtils.getFileUtils().toURI(reportFile.getAbsolutePath()) ); + InputStream reportStream = reportUrl.openStream(); + assertTrue("This shouldnt be an empty stream.", reportStream.available() > 0); } - } \ No newline at end of file