ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r374689 - /ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
Date Fri, 03 Feb 2006 15:26:47 GMT
Author: jhm
Date: Fri Feb  3 07:26:32 2006
New Revision: 374689

URL: http://svn.apache.org/viewcvs?rev=374689&view=rev
Log:
Enhance the Bug 38477 tests.

Modified:
    ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java

Modified: ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java?rev=374689&r1=374688&r2=374689&view=diff
==============================================================================
--- ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
(original)
+++ ant/core/trunk/src/testcases/org/apache/tools/ant/taskdefs/optional/junit/JUnitReportTest.java
Fri Feb  3 07:26:32 2006
@@ -19,6 +19,8 @@
 
 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 @@
     // 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);
     }
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message