ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit BriefJUnitResultFormatter.java
Date Fri, 11 Jan 2002 23:18:30 GMT
sbailliez    02/01/11 15:18:30

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/junit
                        BriefJUnitResultFormatter.java
  Log:
  - Enforce coding guidelines.
  
  Revision  Changes    Path
  1.7       +57 -54    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java
  
  Index: BriefJUnitResultFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/BriefJUnitResultFormatter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BriefJUnitResultFormatter.java	9 Dec 2001 20:58:36 -0000	1.6
  +++ BriefJUnitResultFormatter.java	11 Jan 2002 23:18:30 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -54,10 +54,16 @@
   
   package org.apache.tools.ant.taskdefs.optional.junit;
   
  -import org.apache.tools.ant.BuildException;
  +import java.io.IOException;
  +import java.io.OutputStream;
  +import java.io.PrintWriter;
  +import java.io.StringWriter;
  +import java.text.NumberFormat;
   
  -import junit.framework.Test;
   import junit.framework.AssertionFailedError;
  +import junit.framework.Test;
  +
  +import org.apache.tools.ant.BuildException;
   
   /**
    * Prints plain text output of the test to a specified Writer.
  @@ -69,32 +75,32 @@
    * @see PlainJUnitResultFormatter
    */
   public class BriefJUnitResultFormatter implements JUnitResultFormatter {
  -        
  +
       /**
        * Where to write the log to.
        */
  -    private java.io.OutputStream m_out;
  +    private OutputStream out;
   
       /**
        * Used for writing the results.
        */
  -    private java.io.PrintWriter m_output;
  -    
  +    private PrintWriter output;
  +
       /**
        * Used as part of formatting the results.
        */
  -    private java.io.StringWriter m_results;
  +    private StringWriter results;
   
       /**
        * Used for writing formatted results to.
        */
  -    private java.io.PrintWriter m_resultWriter;
  -    
  +    private PrintWriter resultWriter;
  +
       /**
        * Formatter for timings.
        */
  -    private java.text.NumberFormat m_numberFormat = java.text.NumberFormat.getInstance();
  -    
  +    private NumberFormat numberFormat = NumberFormat.getInstance();
  +
       /**
        * Output suite has written to System.out
        */
  @@ -106,18 +112,18 @@
       private String systemError = null;
   
       public BriefJUnitResultFormatter() {
  -        m_results = new java.io.StringWriter();
  -        m_resultWriter = new java.io.PrintWriter(m_results);
  +        results = new StringWriter();
  +        resultWriter = new PrintWriter(results);
       }
  -    
  +
       /**
        * Sets the stream the formatter is supposed to write its results to.
        */
  -    public void setOutput(java.io.OutputStream out) { 
  -        m_out = out; 
  -        m_output = new java.io.PrintWriter(out); 
  +    public void setOutput(OutputStream out) {
  +        this.out = out;
  +        output = new PrintWriter(out);
       }
  -    
  +
       public void setSystemOutput(String out) {
           systemOutput = out;
       }
  @@ -126,10 +132,7 @@
           systemError = err;
       }
   
  -    protected java.io.PrintWriter output() { return m_output; }
  -    
  -    protected java.io.PrintWriter resultWriter() { return m_resultWriter; }
  -    
  +
       /**
        * The whole testsuite started.
        */
  @@ -151,51 +154,52 @@
           sb.append(", Errors: ");
           sb.append(suite.errorCount());
           sb.append(", Time elapsed: ");
  -        sb.append(m_numberFormat.format(suite.getRunTime()/1000.0));
  +        sb.append(numberFormat.format(suite.getRunTime() / 1000.0));
           sb.append(" sec");
           sb.append(newLine);
           sb.append(newLine);
   
           // append the err and output streams to the log
           if (systemOutput != null && systemOutput.length() > 0) {
  -            sb.append("------------- Standard Output ---------------" )
  -                .append(newLine)
  -                .append(systemOutput)
  -                .append("------------- ---------------- ---------------" )
  -                .append(newLine);
  +            sb.append("------------- Standard Output ---------------")
  +                    .append(newLine)
  +                    .append(systemOutput)
  +                    .append("------------- ---------------- ---------------")
  +                    .append(newLine);
           }
  -        
  +
           if (systemError != null && systemError.length() > 0) {
  -            sb.append("------------- Standard Error -----------------" )
  -                .append(newLine)
  -                .append(systemError)
  -                .append("------------- ---------------- ---------------" )
  -                .append(newLine);
  +            sb.append("------------- Standard Error -----------------")
  +                    .append(newLine)
  +                    .append(systemError)
  +                    .append("------------- ---------------- ---------------")
  +                    .append(newLine);
           }
   
  -        if ( output() != null) {
  +        if (output != null) {
               try {
  -                output().write(sb.toString());
  -                resultWriter().close();
  -                output().write(m_results.toString());
  -                output().flush();
  +                output.write(sb.toString());
  +                resultWriter.close();
  +                output.write(results.toString());
  +                output.flush();
               } finally {
  -                if (m_out != (Object)System.out &&
  -                    m_out != (Object)System.err) {
  +                if (out != System.out &&
  +                        out != System.err) {
                       try {
  -                        m_out.close();
  -                    } catch (java.io.IOException e) {}
  +                        out.close();
  +                    } catch (IOException e) {
  +                    }
                   }
               }
           }
       }
  -    
  +
       /**
        * A test started.
        */
       public void startTest(Test test) {
       }
  -    
  +
       /**
        * A test ended.
        */
  @@ -226,15 +230,14 @@
       public void addError(Test test, Throwable error) {
           formatError("\tCaused an ERROR", test, error);
       }
  -    
  +
       /**
        * Format the test for printing..
        */
       protected String formatTest(Test test) {
           if (test == null) {
               return "Null Test: ";
  -        }
  -        else {
  +        } else {
               return "Testcase: " + test.toString() + ":";
           }
       }
  @@ -242,16 +245,16 @@
       /**
        * Format an error and print it.
        */
  -    protected synchronized void formatError(String type, Test test, 
  +    protected synchronized void formatError(String type, Test test,
                                               Throwable error) {
           if (test != null) {
               endTest(test);
           }
   
  -        resultWriter().println(formatTest(test) + type);
  -        resultWriter().println(error.getMessage());
  +        resultWriter.println(formatTest(test) + type);
  +        resultWriter.println(error.getMessage());
           String strace = JUnitTestRunner.getFilteredTrace(error);
  -        resultWriter().println(strace);
  -        resultWriter().println("");
  +        resultWriter.println(strace);
  +        resultWriter.println();
       }
   }
  
  
  

--
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