ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs PropertyTest.java TaskdefsTest.java
Date Sat, 17 Feb 2001 11:50:05 GMT
conor       01/02/17 03:50:05

  Modified:    src/testcases/org/apache/tools/ant/taskdefs Tag:
                        ANT_13_BRANCH TaskdefsTest.java
  Added:       src/etc/testcases/taskdefs Tag: ANT_13_BRANCH property.xml
               src/testcases/org/apache/tools/ant/taskdefs Tag:
                        ANT_13_BRANCH PropertyTest.java
  Log:
  Implement a test case for the loading of environment variables with
  the property task. The test is fairly simple - it just tests that the
  task does not generate any output on System.out or System.err
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +8 -0      jakarta-ant/src/etc/testcases/taskdefs/Attic/property.xml
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +33 -9     jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java
  
  Index: TaskdefsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -r1.3 -r1.3.2.1
  --- TaskdefsTest.java	2001/01/03 14:18:49	1.3
  +++ TaskdefsTest.java	2001/02/17 11:50:03	1.3.2.1
  @@ -67,6 +67,7 @@
       
       private StringBuffer logBuffer;
       private StringBuffer outBuffer;
  +    private StringBuffer errBuffer;
       private BuildException buildException;
       
       public TaskdefsTest(String name) {
  @@ -92,33 +93,50 @@
           assertEquals(output, realOutput);
       }
   
  +    protected void expectOutputAndError(String taskname, String output, String error) {

  +        executeTarget(taskname);
  +        String realOutput = getOutput();
  +        assertEquals(output, realOutput);
  +        String realError = getError();
  +        assertEquals(error, realError);
  +    }
  +
       protected void expectLog(String taskname, String log) { 
           executeTarget(taskname);
           String realLog = getLog();
           assertEquals(log, realLog);
       }
   
  -    protected String getOutput() { 
  -        StringBuffer cleanOut = new StringBuffer();
  +    
  +    protected String getOutput() {
  +        return cleanBuffer(outBuffer);
  +    }
  +     
  +    protected String getError() {
  +        return cleanBuffer(errBuffer);
  +    }
  +        
  +    private String cleanBuffer(StringBuffer buffer) {
  +        StringBuffer cleanedBuffer = new StringBuffer();
           boolean cr = false;
  -        for (int i = 0; i < outBuffer.length(); i++) { 
  -            char ch = outBuffer.charAt(i);
  +        for (int i = 0; i < buffer.length(); i++) { 
  +            char ch = buffer.charAt(i);
               if (ch == '\r') {
                   cr = true;
                   continue;
               }
   
               if (!cr) { 
  -                cleanOut.append(ch);
  +                cleanedBuffer.append(ch);
               } else { 
                   if (ch == '\n') {
  -                    cleanOut.append(ch);
  +                    cleanedBuffer.append(ch);
                   } else {
  -                    cleanOut.append('\r').append(ch);
  +                    cleanedBuffer.append('\r').append(ch);
                   }
               }
           }
  -        return cleanOut.toString();
  +        return cleanedBuffer.toString();
       }
       
       protected void configureProject(String filename) { 
  @@ -131,16 +149,22 @@
       
       protected void executeTarget(String targetName) { 
           PrintStream sysOut = System.out;
  +        PrintStream sysErr = System.err;
           try { 
  -            outBuffer = new StringBuffer();
               sysOut.flush();
  +            sysErr.flush();
  +            outBuffer = new StringBuffer();
               PrintStream out = new PrintStream(new AntOutputStream());
               System.setOut(out);
  +            errBuffer = new StringBuffer();
  +            PrintStream err = new PrintStream(new AntOutputStream());
  +            System.setErr(err);
               logBuffer = new StringBuffer();
               buildException = null;
               project.executeTarget(targetName);
           } finally { 
               System.setOut(sysOut);
  +            System.setErr(sysErr);
           }
           
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +74 -0     jakarta-ant/src/testcases/org/apache/tools/ant/taskdefs/Attic/PropertyTest.java
  
  
  
  

Mime
View raw message