From d95378821a72fafbd608fc101ed6578f6b492940 Mon Sep 17 00:00:00 2001 From: Jan Materne Date: Fri, 3 Feb 2006 15:26:32 +0000 Subject: [PATCH] Enhance the Bug 38477 tests. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@374689 13f79535-47bb-0310-9956-ffa450edef68 --- .../optional/junit/JUnitReportTest.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) 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