You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ke...@apache.org on 2006/02/06 05:41:44 UTC
svn commit: r375172 - in
/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit:
BriefJUnitResultFormatter.java PlainJUnitResultFormatter.java
Author: kevj
Date: Sun Feb 5 20:41:43 2006
New Revision: 375172
URL: http://svn.apache.org/viewcvs?rev=375172&view=rev
Log:
use StringUtils and FileUtils where possible
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java?rev=375172&r1=375171&r2=375172&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java Sun Feb 5 20:41:43 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2001-2002,2004-2005 The Apache Software Foundation
+ * Copyright 2001-2002,2004-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,14 +17,17 @@
package org.apache.tools.ant.taskdefs.optional.junit;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.NumberFormat;
+
import junit.framework.AssertionFailedError;
import junit.framework.Test;
+import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.StringUtils;
+
/**
* Prints plain text output of the test to a specified Writer.
* Inspired by the PlainJUnitResultFormatter.
@@ -109,10 +112,9 @@
if (output == null) {
return; // Quick return - no output do nothing.
}
- String newLine = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer("Testsuite: ");
sb.append(suite.getName());
- sb.append(newLine);
+ sb.append(StringUtils.LINE_SEP);
output.write(sb.toString());
output.flush();
}
@@ -122,7 +124,6 @@
* @param suite the test suite
*/
public void endTestSuite(JUnitTest suite) {
- String newLine = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer("Tests run: ");
sb.append(suite.runCount());
sb.append(", Failures: ");
@@ -132,24 +133,24 @@
sb.append(", Time elapsed: ");
sb.append(numberFormat.format(suite.getRunTime() / 1000.0));
sb.append(" sec");
- sb.append(newLine);
- sb.append(newLine);
+ sb.append(StringUtils.LINE_SEP);
+ sb.append(StringUtils.LINE_SEP);
// append the err and output streams to the log
if (systemOutput != null && systemOutput.length() > 0) {
sb.append("------------- Standard Output ---------------")
- .append(newLine)
+ .append(StringUtils.LINE_SEP)
.append(systemOutput)
.append("------------- ---------------- ---------------")
- .append(newLine);
+ .append(StringUtils.LINE_SEP);
}
if (systemError != null && systemError.length() > 0) {
sb.append("------------- Standard Error -----------------")
- .append(newLine)
+ .append(StringUtils.LINE_SEP)
.append(systemError)
.append("------------- ---------------- ---------------")
- .append(newLine);
+ .append(StringUtils.LINE_SEP);
}
if (output != null) {
@@ -160,11 +161,7 @@
output.flush();
} finally {
if (out != System.out && out != System.err) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
+ FileUtils.close(out);
}
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java
URL: http://svn.apache.org/viewcvs/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java?rev=375172&r1=375171&r2=375172&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/PlainJUnitResultFormatter.java Sun Feb 5 20:41:43 2006
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2004 The Apache Software Foundation
+ * Copyright 2000-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,9 +23,13 @@
import java.io.StringWriter;
import java.text.NumberFormat;
import java.util.Hashtable;
+
import junit.framework.AssertionFailedError;
import junit.framework.Test;
+
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.util.FileUtils;
+import org.apache.tools.ant.util.StringUtils;
/**
@@ -89,10 +93,9 @@
if (out == null) {
return; // Quick return - no output do nothing.
}
- String newLine = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer("Testsuite: ");
sb.append(suite.getName());
- sb.append(newLine);
+ sb.append(StringUtils.LINE_SEP);
try {
out.write(sb.toString().getBytes());
out.flush();
@@ -107,7 +110,6 @@
* @throws BuildException if unable to write the output
*/
public void endTestSuite(JUnitTest suite) throws BuildException {
- String newLine = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer("Tests run: ");
sb.append(suite.runCount());
sb.append(", Failures: ");
@@ -117,26 +119,26 @@
sb.append(", Time elapsed: ");
sb.append(nf.format(suite.getRunTime() / 1000.0));
sb.append(" sec");
- sb.append(newLine);
+ sb.append(StringUtils.LINE_SEP);
// append the err and output streams to the log
if (systemOutput != null && systemOutput.length() > 0) {
sb.append("------------- Standard Output ---------------")
- .append(newLine)
+ .append(StringUtils.LINE_SEP)
.append(systemOutput)
.append("------------- ---------------- ---------------")
- .append(newLine);
+ .append(StringUtils.LINE_SEP);
}
if (systemError != null && systemError.length() > 0) {
sb.append("------------- Standard Error -----------------")
- .append(newLine)
+ .append(StringUtils.LINE_SEP)
.append(systemError)
.append("------------- ---------------- ---------------")
- .append(newLine);
+ .append(StringUtils.LINE_SEP);
}
- sb.append(newLine);
+ sb.append(StringUtils.LINE_SEP);
if (out != null) {
try {
@@ -148,11 +150,7 @@
throw new BuildException("Unable to write output", ioex);
} finally {
if (out != System.out && out != System.err) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
+ FileUtils.close(out);
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org