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/proposal/sandbox/input/src/testcases/org/apache/tools/ant/taskdefs InputTest.java
Date Thu, 11 Apr 2002 14:43:05 GMT
bodewig     02/04/11 07:43:05

  Modified:    proposal/sandbox/input/src/main/org/apache/tools/ant/taskdefs
                        Input.java
               proposal/sandbox/input/src/testcases/org/apache/tools/ant/taskdefs
                        InputTest.java
  Log:
  Make use of StringUtils, cosmetics.
  
  Revision  Changes    Path
  1.2       +6 -7      jakarta-ant/proposal/sandbox/input/src/main/org/apache/tools/ant/taskdefs/Input.java
  
  Index: Input.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/input/src/main/org/apache/tools/ant/taskdefs/Input.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Input.java	25 Feb 2002 16:10:16 -0000	1.1
  +++ Input.java	11 Apr 2002 14:43:05 -0000	1.2
  @@ -54,7 +54,6 @@
   
   package org.apache.tools.ant.taskdefs;
   
  -import  java.util.StringTokenizer;
   import  java.util.Vector;
   
   import org.apache.tools.ant.BuildException;
  @@ -62,11 +61,15 @@
   import org.apache.tools.ant.Task;
   import org.apache.tools.ant.input.InputRequest;
   import org.apache.tools.ant.input.MultipleChoiceInputRequest;
  +import org.apache.tools.ant.util.StringUtils;
   
   /**
    * Ant task to read input line from console.
    *
    * @author <a href="mailto:usch@usch.net">Ulrich Schmidt</a>
  + * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  + *
  + * @since Ant 1.5
    */
   public class Input extends Task {
       private String validargs = null;
  @@ -124,11 +127,7 @@
       public void execute () throws BuildException {
           InputRequest request = null;
           if (validargs != null) {
  -            Vector accept = new Vector();
  -            StringTokenizer stok = new StringTokenizer(validargs, ",", false);
  -            while (stok.hasMoreTokens()) {
  -                accept.addElement(stok.nextToken());
  -            }
  +            Vector accept = StringUtils.split(validargs, ',');
               request = new MultipleChoiceInputRequest(message, accept);
           } else {
               request = new InputRequest(message);
  @@ -138,7 +137,7 @@
   
           if (addproperty != null) {
               if (project.getProperty(addproperty) == null) {
  -                project.setProperty(addproperty, request.getInput());
  +                project.setNewProperty(addproperty, request.getInput());
               } else {
                   log("Override ignored for " + addproperty,
                       Project.MSG_VERBOSE);
  
  
  
  1.2       +8 -9      jakarta-ant/proposal/sandbox/input/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java
  
  Index: InputTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/input/src/testcases/org/apache/tools/ant/taskdefs/InputTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- InputTest.java	26 Feb 2002 10:29:29 -0000	1.1
  +++ InputTest.java	11 Apr 2002 14:43:05 -0000	1.2
  @@ -59,6 +59,7 @@
   
   /**
    * @author Ulrich Schmidt <usch@usch.net>
  + * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    */
   public class InputTest extends BuildFileTest {
   
  @@ -67,8 +68,9 @@
       }
   
       public void setUp() {
  -        System.getProperties().put(PropertyFileInputHandler.FILE_NAME_KEY,
  -                                   "src/etc/testcases/taskdefs/input.properties");
  +        System.getProperties()
  +            .put(PropertyFileInputHandler.FILE_NAME_KEY,
  +                 "src/etc/testcases/taskdefs/input.properties");
           configureProject("src/etc/testcases/taskdefs/input.xml");
           getProject().setInputHandler(new PropertyFileInputHandler());
       }
  @@ -82,13 +84,10 @@
       }
   
       public void test3() {
  -        try {
  -            executeTarget("test3");
  -            fail("Input for \"All data is going to be deleted from DB continue?\" should
be invalid");
  -        } catch (org.apache.tools.ant.BuildException e) {
  -            assertEquals("Found invalid input test for All data is going to be deleted
from DB continue?", 
  -                         e.getMessage());
  -        }
  +        expectSpecificBuildException("test3", "invalid input",
  +                                     "Found invalid input test for All data is"
  +                                     + " going to be deleted from DB"
  +                                     + " continue?");
       }
   
       public void test5() {
  
  
  

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