roxspring    2004/12/27 05:33:48

  Modified:    cli/src/test/org/apache/commons/cli BugsTest.java
  Log:
  Added test to demonstrate the 27635 has been fixed
  
  PR: 27635
  
  Revision  Changes    Path
  1.20      +69 -0     
jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java
  
  Index: BugsTest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/BugsTest.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BugsTest.java     6 Sep 2004 22:51:45 -0000       1.19
  +++ BugsTest.java     27 Dec 2004 13:33:48 -0000      1.20
  @@ -17,6 +17,7 @@
   
   import java.io.ByteArrayOutputStream;
   import java.io.PrintStream;
  +import java.io.PrintWriter;
   import java.io.StringWriter;
   
   import junit.framework.Test;
  @@ -409,6 +410,74 @@
           options.addOption( m );
           CommandLine line = parser.parse( options, args );
           assertEquals( "Two Words", line.getOptionValue( "m" ) );
  +    }
  +
  +    public void test27635() {
  +        Option help = new Option("h", "help", false, "print this message");
  +        Option version = new Option("v", "version", false, "print version 
information");
  +        Option newRun = new Option("n", "new", false, "Create NLT cache 
entries only for new items");
  +        Option trackerRun = new Option("t", "tracker", false, "Create NLT 
cache entries only for tracker items");
  +        
  +        Option timeLimit = OptionBuilder.withLongOpt("limit")
  +                                        .hasArg()
  +                                        .withValueSeparator()
  +                                        .withDescription("Set time limit for 
execution, in mintues")
  +                                        .create("l");
  +        
  +        Option age = OptionBuilder.withLongOpt("age")
  +                                        .hasArg()
  +                                        .withValueSeparator()
  +                                        .withDescription("Age (in days) of 
cache item before being recomputed")
  +                                        .create("a");
  +        
  +        Option server = OptionBuilder.withLongOpt("server")
  +                                        .hasArg()
  +                                        .withValueSeparator()
  +                                        .withDescription("The NLT server 
address")
  +                                        .create("s");
  +        
  +        Option numResults = OptionBuilder.withLongOpt("results")
  +                                        .hasArg()
  +                                        .withValueSeparator()
  +                                        .withDescription("Number of results 
per item")
  +                                        .create("r");
  +        
  +        Option configFile = OptionBuilder.withLongOpt("config")
  +                                        .hasArg()
  +                                        .withValueSeparator()
  +                                        .withDescription("Use the specified 
configuration file")
  +                                        .create();
  +        
  +        Options mOptions = new Options();
  +        mOptions.addOption(help);
  +        mOptions.addOption(version);
  +        mOptions.addOption(newRun);
  +        mOptions.addOption(trackerRun);
  +        mOptions.addOption(timeLimit);
  +        mOptions.addOption(age);
  +        mOptions.addOption(server);
  +        mOptions.addOption(numResults);
  +        mOptions.addOption(configFile);
  +        
  +        HelpFormatter formatter = new HelpFormatter();
  +        final String EOL = System.getProperty("line.separator");
  +        StringWriter out = new StringWriter();
  +        formatter.printHelp(new 
PrintWriter(out),80,"commandline","header",mOptions,2,2,"footer",true);
  +        assertEquals(
  +                "usage: commandline [--config <arg>] [-r <arg>] [-a <arg>] 
[-h] [-t] [-n] [-l"+EOL+
  +                "       <arg>] [-s <arg>] [-v]"+EOL+
  +                "header"+EOL+
  +                "  -a,--age <arg>      Age (in days) of cache item before 
being recomputed"+EOL+
  +                "     --config <arg>   Use the specified configuration 
file"+EOL+
  +                "  -h,--help           print this message"+EOL+
  +                "  -l,--limit <arg>    Set time limit for execution, in 
mintues"+EOL+
  +                "  -n,--new            Create NLT cache entries only for new 
items"+EOL+
  +                "  -r,--results <arg>  Number of results per item"+EOL+
  +                "  -s,--server <arg>   The NLT server address"+EOL+
  +                "  -t,--tracker        Create NLT cache entries only for 
tracker items"+EOL+
  +                "  -v,--version        print version information"+EOL+
  +                "footer"+EOL
  +                ,out.toString());
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to