From andrus@objectstyle.org Thu Apr 3 21:37:21 2003 Return-Path: Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Delivered-To: mailing list dev@ant.apache.org Received: (qmail 66632 invoked from network); 3 Apr 2003 21:37:21 -0000 Received: from user-vc8f0p3.biz.mindspring.com (HELO mail.objectstyle.org) (216.135.131.35) by daedalus.apache.org with SMTP; 3 Apr 2003 21:37:21 -0000 Received: (qmail 25622 invoked from network); 3 Apr 2003 21:42:07 -0000 Received: from unknown (HELO objectstyle.org) (66.151.218.42) by mail.objectstyle.org with SMTP; 3 Apr 2003 21:42:07 -0000 Date: Thu, 3 Apr 2003 16:37:30 -0500 Mime-Version: 1.0 (Apple Message framework v551) Content-Type: multipart/mixed; boundary=Apple-Mail-9-231689706 Subject: [PATCH] JUnitReport Patch From: Andrus Adamchik To: dev@ant.apache.org Message-Id: <78AECC8D-661C-11D7-B05B-000393B62590@objectstyle.org> X-Mailer: Apple Mail (2.551) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --Apple-Mail-9-231689706 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed I submitted a bug 18504 about JUnitReport being broken on JDK 1.4.1. It was closed with WONTFIX status, which I think happened partially due to Bugzilla mysteriously trimming half of my report text (I am not very experienced with Bugzilla, so who knows). Anyway, the description was mangled causing confusion. In the meantime Cayenne team member who gave me the original description fixed it in Ant and sent me a patch, attached to this message. All I can tell is that patched version completely fixes the problem and we already use it in Cayenne builds. Andrus Adamchik http://objectstyle.org/cayenne/ --Apple-Mail-9-231689706 Content-Disposition: attachment; filename=diff.txt Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; x-unix-mode=0755; name="diff.txt" diff -ur = ant/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.j= ava = ant-patched/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFor= matter.java --- = ant/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.j= ava 2003-02-28 10:07:08.000000000 +0100 +++ = ant-patched/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFor= matter.java 2003-04-03 20:17:14.000000000 +0200 @@ -54,14 +54,11 @@ =0D package org.apache.tools.ant.taskdefs.optional.junit;=0D =0D +import java.io.BufferedWriter;=0D import java.io.OutputStream;=0D import java.io.Writer;=0D import java.io.OutputStreamWriter;=0D import java.io.IOException;=0D -=0D -=0D -=0D -=0D import java.util.Properties;=0D import java.util.Enumeration;=0D import java.util.Hashtable;=0D @@ -166,7 +163,7 @@ if (out !=3D null) {=0D Writer wri =3D null;=0D try {=0D - wri =3D new OutputStreamWriter(out, "UTF8");=0D + wri =3D new BufferedWriter(new OutputStreamWriter(out, = "UTF8"));=0D wri.write("\n");=0D (new DOMElementWriter()).write(rootElement, wri, 0, " = ");=0D wri.flush();=0D diff -ur = ant/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java = ant-patched/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregat= or.java --- = ant/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java = 2003-02-28 10:07:30.000000000 +0100 +++ = ant-patched/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregat= or.java 2003-03-31 00:19:34.000000000 +0200 @@ -53,30 +53,30 @@ */=0D package org.apache.tools.ant.taskdefs.optional.junit;=0D =0D +import java.io.BufferedOutputStream;=0D +import java.io.BufferedWriter;=0D import java.io.File;=0D +import java.io.FileOutputStream;=0D import java.io.IOException;=0D import java.io.OutputStream;=0D import java.io.OutputStreamWriter;=0D import java.io.PrintWriter;=0D -=0D -import java.io.FileOutputStream;=0D import java.util.Enumeration;=0D import java.util.Vector;=0D =0D -import org.w3c.dom.Element;=0D -import org.w3c.dom.Document;=0D -=0D -=0D -import org.xml.sax.SAXException;=0D import javax.xml.parsers.DocumentBuilder;=0D import javax.xml.parsers.DocumentBuilderFactory;=0D +=0D +import org.apache.tools.ant.BuildException;=0D +import org.apache.tools.ant.DirectoryScanner;=0D import org.apache.tools.ant.Project;=0D import org.apache.tools.ant.Task;=0D -import org.apache.tools.ant.DirectoryScanner;=0D -import org.apache.tools.ant.BuildException;=0D import org.apache.tools.ant.types.FileSet;=0D import org.apache.tools.ant.util.DOMElementWriter;=0D import org.apache.tools.ant.util.StringUtils;=0D +import org.w3c.dom.Document;=0D +import org.w3c.dom.Element;=0D +import org.xml.sax.SAXException;=0D =0D =0D /**=0D @@ -161,17 +161,18 @@ public void execute() throws BuildException {=0D Element rootElement =3D createDocument();=0D File destFile =3D getDestinationFile();=0D +=0D // write the document=0D try {=0D writeDOMTree(rootElement.getOwnerDocument(), destFile);=0D } catch (IOException e){=0D throw new BuildException("Unable to write test aggregate to = '" + destFile + "'", e);=0D }=0D +=0D // apply transformation=0D Enumeration enum =3D transformers.elements();=0D while (enum.hasMoreElements()) {=0D - AggregateTransformer transformer =3D=0D - (AggregateTransformer) enum.nextElement();=0D + AggregateTransformer transformer =3D (AggregateTransformer) = enum.nextElement();=0D transformer.setXmlDocument(rootElement.getOwnerDocument());=0D= transformer.transform();=0D }=0D @@ -232,8 +233,8 @@ OutputStream out =3D null;=0D PrintWriter wri =3D null;=0D try {=0D - out =3D new FileOutputStream(file);=0D - wri =3D new PrintWriter(new OutputStreamWriter(out, = "UTF8"));=0D + out =3D new BufferedOutputStream(new = FileOutputStream(file));=0D + wri =3D new PrintWriter(new BufferedWriter(new = OutputStreamWriter(out, "UTF8")));=0D wri.write("\n");=0D (new DOMElementWriter()).write(doc.getDocumentElement(), = wri, 0, " ");=0D wri.flush();=0D diff -ur = ant/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java = ant-patched/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.jav= a --- ant/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java = 2003-02-28 10:07:44.000000000 +0100 +++ = ant-patched/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.jav= a 2003-04-03 20:15:22.000000000 +0200 @@ -56,6 +56,7 @@ import org.apache.tools.ant.BuildException;=0D import org.apache.tools.ant.Project;=0D =0D +import java.io.BufferedOutputStream;=0D import java.io.File;=0D import java.io.IOException;=0D import java.io.OutputStream;=0D @@ -83,12 +84,12 @@ =0D /** get the appropriate stream based on the format = (frames/noframes) */=0D protected OutputStream getOutputStream() throws IOException {=0D - if (caller.FRAMES.equals(caller.format)){=0D + if (AggregateTransformer.FRAMES.equals(caller.format)){=0D // dummy output for the framed report=0D // it's all done by extension...=0D return new ByteArrayOutputStream();=0D } else {=0D - return new FileOutputStream(new File(caller.toDir, = "junit-noframes.html"));=0D + return new BufferedOutputStream(new FileOutputStream(new = File(caller.toDir, "junit-noframes.html")));=0D }=0D }=0D =0D diff -ur ant/org/apache/tools/ant/util/DOMElementWriter.java = ant-patched/org/apache/tools/ant/util/DOMElementWriter.java --- ant/org/apache/tools/ant/util/DOMElementWriter.java 2003-02-28 = 10:05:52.000000000 +0100 +++ ant-patched/org/apache/tools/ant/util/DOMElementWriter.java = 2003-04-03 19:44:42.000000000 +0200 @@ -55,15 +55,15 @@ package org.apache.tools.ant.util;=0D =0D import java.io.IOException;=0D -import java.io.Writer;=0D import java.io.OutputStream;=0D import java.io.OutputStreamWriter;=0D +import java.io.Writer;=0D =0D +import org.w3c.dom.Attr;=0D import org.w3c.dom.Element;=0D import org.w3c.dom.NamedNodeMap;=0D -import org.w3c.dom.Attr;=0D -import org.w3c.dom.NodeList;=0D import org.w3c.dom.Node;=0D +import org.w3c.dom.NodeList;=0D import org.w3c.dom.Text;=0D =0D /**=0D @@ -206,7 +206,7 @@ */=0D public String encode(String value) {=0D sb.setLength(0);=0D - for (int i =3D 0; i < value.length(); i++) {=0D + for (int i =3D 0, vlength =3D value.length(); i < vlength; i++) = {=0D char c =3D value.charAt(i);=0D switch (c) {=0D case '<':=0D @@ -237,7 +237,8 @@ break;=0D }=0D }=0D - return sb.toString();=0D + // fix for JDK 1.4.1 StringBuffer bug #4724129=0D + return sb.substring(0);=0D }=0D =0D /**=0D @@ -251,7 +252,6 @@ * = href=3D"http://www.w3.org/TR/1998/REC-xml-19980210#charsets">http://www.w3= .org/TR/1998/REC-xml-19980210#charsets and=0D * 2.7 http://= www.w3.org/TR/1998/REC-xml-19980210#sec-cdata-sect.

=0D -=0D */=0D public String encodedata(final String value) {=0D sb.setLength(0);=0D @@ -262,13 +262,14 @@ }=0D }=0D =0D - String result =3D sb.toString();=0D + // fix for JDK 1.4.1 StringBuffer bug #4724129=0D + String result =3D sb.substring(0);=0D int cdEnd =3D result.indexOf("]]>");=0D while (cdEnd !=3D -1) {=0D sb.setLength(cdEnd);=0D sb.append("]]>")=0D .append(result.substring(cdEnd+3));=0D - result =3D sb.toString();=0D + result =3D sb.substring(0);=0D cdEnd =3D result.indexOf("]]>");=0D }=0D =0D --Apple-Mail-9-231689706--