ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit XMLResultAggregator.java Xalan1Executor.java Xalan2Executor.java XalanExecutor.java
Date Wed, 03 Apr 2002 13:18:03 GMT
bodewig     02/04/03 05:18:03

  Modified:    .        build.xml
               src/main/org/apache/tools/ant/taskdefs/optional/junit
                        XMLResultAggregator.java Xalan1Executor.java
                        Xalan2Executor.java XalanExecutor.java
  Log:
  close streams in junitreport.
  
  PR: 6852
  
  Make XalanExecutor independent of Xalan2 so one can compile
  Xalan1Executor without Xalan2.
  
  Revision  Changes    Path
  1.276     +0 -2      jakarta-ant/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/build.xml,v
  retrieving revision 1.275
  retrieving revision 1.276
  diff -u -r1.275 -r1.276
  --- build.xml	2 Apr 2002 11:56:49 -0000	1.275
  +++ build.xml	3 Apr 2002 13:18:02 -0000	1.276
  @@ -188,8 +188,6 @@
                unless="xalan2.present" />
       <exclude name="${optional.package}/junit/AggregateTransformer.java"
                unless="xalan2.present" />
  -    <exclude name="${optional.package}/junit/XalanExecutor.java"
  -             unless="xalan2.present" />
       <exclude name="${optional.package}/junit/Xalan2Executor.java"
                unless="xalan2.present" />
     </patternset>
  
  
  
  1.14      +20 -9     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java
  
  Index: XMLResultAggregator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLResultAggregator.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XMLResultAggregator.java	3 Mar 2002 01:46:23 -0000	1.13
  +++ XMLResultAggregator.java	3 Apr 2002 13:18:03 -0000	1.14
  @@ -226,15 +226,26 @@
        * @throws IOException thrown if there is an error while writing the content.
        */
       protected void writeDOMTree(Document doc, File file) throws IOException {
  -        OutputStream out = new FileOutputStream( file );
  -        PrintWriter wri = new PrintWriter(new OutputStreamWriter(out, "UTF8"));
  -        wri.write("<?xml version=\"1.0\"?>\n");
  -        (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, "  ");
  -        wri.flush();
  -        wri.close();
  -        // writers do not throw exceptions, so check for them.
  -        if (wri.checkError()){
  -            throw new IOException("Error while writing DOM content");
  +        OutputStream out = null;
  +        PrintWriter wri = null;
  +        try {
  +            out = new FileOutputStream( file );
  +            wri = new PrintWriter(new OutputStreamWriter(out, "UTF8"));
  +            wri.write("<?xml version=\"1.0\"?>\n");
  +            (new DOMElementWriter()).write(doc.getDocumentElement(), wri, 0, "  ");
  +            wri.flush();
  +            // writers do not throw exceptions, so check for them.
  +            if (wri.checkError()){
  +                throw new IOException("Error while writing DOM content");
  +            }
  +        } finally {
  +            if (wri != null) {
  +                wri.close();
  +                out = null;
  +            }
  +            if (out != null) {
  +                out.close();
  +            }
           }
       }
   
  
  
  
  1.7       +6 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java
  
  Index: Xalan1Executor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Xalan1Executor.java	5 Mar 2002 03:28:31 -0000	1.6
  +++ Xalan1Executor.java	3 Apr 2002 13:18:03 -0000	1.7
  @@ -76,7 +76,11 @@
           String system_id = caller.getStylesheetSystemId();
           XSLTInputSource xsl_src = new XSLTInputSource(system_id);
           OutputStream os = getOutputStream();
  -        XSLTResultTarget target = new XSLTResultTarget(os);
  -        processor.process( xml_src, xsl_src, target);
  +        try {
  +            XSLTResultTarget target = new XSLTResultTarget(os);
  +            processor.process( xml_src, xsl_src, target);
  +        } finally {
  +            os.close();
  +        }
       }
   }
  
  
  
  1.5       +7 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java
  
  Index: Xalan2Executor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Xalan2Executor.java	7 Mar 2002 16:10:39 -0000	1.4
  +++ Xalan2Executor.java	3 Apr 2002 13:18:03 -0000	1.5
  @@ -77,8 +77,12 @@
           Transformer tformer = tfactory.newTransformer(xsl_src);
           Source xml_src = new DOMSource(caller.document);
           OutputStream os = getOutputStream();
  -        tformer.setParameter("output.dir", caller.toDir.getAbsolutePath());
  -        Result result = new StreamResult(os);
  -        tformer.transform(xml_src, result);
  +        try {
  +            tformer.setParameter("output.dir", caller.toDir.getAbsolutePath());
  +            Result result = new StreamResult(os);
  +            tformer.transform(xml_src, result);
  +        } finally {
  +            os.close();
  +        }
       }
   }
  
  
  
  1.4       +3 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java
  
  Index: XalanExecutor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XalanExecutor.java	10 Jan 2002 13:59:37 -0000	1.3
  +++ XalanExecutor.java	3 Apr 2002 13:18:03 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -105,7 +105,8 @@
           XalanExecutor executor = null;
           try {
               procVersion = Class.forName("org.apache.xalan.processor.XSLProcessorVersion");
  -            executor = new Xalan2Executor();
  +            executor = (XalanExecutor) Class.forName(
  +                "org.apache.tools.ant.taskdefs.optional.junit.Xalan2Executor").newInstance();
           } catch (Exception xalan2missing){
               try {
                   procVersion = Class.forName("org.apache.xalan.xslt.XSLProcessorVersion");
  
  
  

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


Mime
View raw message