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/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter Resources.properties SummaryFormatter.java BriefFormatter.java XMLFormatter.java
Date Mon, 14 Jan 2002 00:26:04 GMT
sbailliez    02/01/13 16:26:04

  Modified:    proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java
               proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter
                        SummaryFormatter.java BriefFormatter.java
                        XMLFormatter.java
  Added:       proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        Resources.properties
               proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter
                        Resources.properties
  Log:
  - Introducing i18 resources management. I'm using
  the i18n package from Excalibur there is no point
  in reinventing the wheel.
  
  Revision  Changes    Path
  1.6       +8 -2      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JUnitTask.java	13 Jan 2002 23:40:11 -0000	1.5
  +++ JUnitTask.java	14 Jan 2002 00:26:04 -0000	1.6
  @@ -74,6 +74,8 @@
   import org.apache.tools.ant.types.CommandlineJava;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.util.FileUtils;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +import org.apache.avalon.excalibur.i18n.Resources;
   
   /**
    * The core JUnit task.
  @@ -82,6 +84,9 @@
    */
   public class JUnitTask extends Task {
   
  +    private final static Resources RES =
  +        ResourceManager.getPackageResources( JUnitTask.class );
  +
       /** port to run the server on */
       private int port = -1;
   
  @@ -111,12 +116,13 @@
           execute.setCommandline(cmd.getCommandline());
           execute.setAntRun(project);
   
  -        log("Executing: " + cmd.toString(), Project.MSG_VERBOSE);
  +        log(RES.getString("task.process-cmdline.log", cmd.toString()), Project.MSG_VERBOSE);
           int retVal;
           try {
               retVal = execute.execute();
           } catch (IOException e) {
  -            throw new BuildException("Process fork failed.", e, location);
  +            String msg = RES.getString("task.process-failed.error");
  +            throw new BuildException(msg, e, location);
           } finally {
               tmp.delete();
           }
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  # task
  task.process-cmdline.log = Executing {0}
  task.process-failed.error = Process failed.
  
  
  1.5       +11 -17    jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/SummaryFormatter.java
  
  Index: SummaryFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/SummaryFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SummaryFormatter.java	13 Jan 2002 23:40:11 -0000	1.4
  +++ SummaryFormatter.java	14 Jan 2002 00:26:04 -0000	1.5
  @@ -56,6 +56,9 @@
   import java.io.PrintWriter;
   import java.text.MessageFormat;
   
  +import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
  +
   /**
    * Display a summary message at the end of a testsuite stating
    * runs, failures, errors, and elapsed time.
  @@ -64,25 +67,16 @@
    */
   public class SummaryFormatter extends BaseFormatter {
   
  -    protected final MessageFormat mf = new MessageFormat(
  -            "Tests run: {0, number, integer}" +
  -            ", Failures: {1, number, integer}" +
  -            ", Errors: {2, number, integer}" +
  -            ", Time elapsed: {3, number, integer} sec");
  +    private final static Resources RES =
  +        ResourceManager.getPackageResources( SummaryFormatter.class );
   
       protected void finished(long elapsedtime) {
  -        PrintWriter writer = getWriter();
  -        writer.print("Testsuite: ");
  -        writer.println();
  -        String line = mf.format(new Object[]{
  -            new Integer(getRunCount()),
  -            new Integer(getFailureCount()),
  -            new Integer(getErrorCount()),
  -            new Long(elapsedtime / 1000)
  -        });
  -        writer.print(line);
  -        writer.println();
  -        writer.println();
  +        String msg = RES.getString("summary.finished.msg",
  +                new Integer(getRunCount()),
  +                new Integer(getFailureCount()),
  +                new Integer(getErrorCount()),
  +                new Long(elapsedtime / 1000) );
  +        getWriter().println(msg);
           close();
       }
   
  
  
  
  1.5       +10 -10    jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/BriefFormatter.java
  
  Index: BriefFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/BriefFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BriefFormatter.java	13 Jan 2002 23:40:11 -0000	1.4
  +++ BriefFormatter.java	14 Jan 2002 00:26:04 -0000	1.5
  @@ -55,6 +55,8 @@
   
   import java.io.PrintWriter;
   
  +import org.apache.avalon.excalibur.i18n.Resources;
  +import org.apache.avalon.excalibur.i18n.ResourceManager;
   
   /**
    * Display additional messages from a <tt>SummaryFormatter</tt>
  @@ -64,19 +66,17 @@
    */
   public class BriefFormatter extends SummaryFormatter {
   
  +    private final static Resources RES =
  +        ResourceManager.getPackageResources( BriefFormatter.class );
  +
       public void onTestFailed(int status, String testname, String trace) {
  -        PrintWriter writer = getWriter();
  -        writer.print("TestCase: ");
  -        writer.print(testname);
  +        String msg = null;
           if (status == STATUS_ERROR) {
  -            writer.print("\tCaused an ERROR");
  -        } else if (status == STATUS_FAILURE) {
  -            writer.write("\tFAILED");
  +            msg = RES.getString("brief.status-error.msg", testname, trace);
  +        } else {
  +            msg = RES.getString("brief.status-failure.msg", testname, trace);
           }
  -        writer.println();
  -        writer.print(trace);
  -        writer.println();
  -        writer.println();
  +        getWriter().println(msg);
           super.onTestFailed(status, testname, trace);
       }
   
  
  
  
  1.5       +3 -0      jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/XMLFormatter.java
  
  Index: XMLFormatter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/XMLFormatter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XMLFormatter.java	13 Jan 2002 23:40:11 -0000	1.4
  +++ XMLFormatter.java	14 Jan 2002 00:26:04 -0000	1.5
  @@ -62,6 +62,9 @@
   import org.w3c.dom.Text;
   
   /**
  + * XML Formatter. Due to the nature of the XML we are forced to store
  + * everything in memory until it is finished. It might be resource
  + * intensive when running lots of testcases.
    *
    * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
    */
  
  
  
  1.1                  jakarta-ant/proposal/sandbox/junit/src/main/org/apache/tools/ant/taskdefs/optional/junit/formatter/Resources.properties
  
  Index: Resources.properties
  ===================================================================
  # Summary formatter
  summary.finished.msg = TestSuite: \nTests run: {0, number, integer}, Failures: {1, number,
integer}, Errors: {2, number, integer}, Time elapsed: {3, number, integer} sec\n
  
  # Brief formatter
  brief.status-error.msg = TestCase: {0}\tCaused an ERROR\n{1}\n
  brief.status-failure.msg = TestCase: {0}\tFAILED\n{1}\n
  
  
  
  

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