commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject cvs commit: jakarta-commons/cli/src/test/org/apache/commons/cli BugsTest.java
Date Sun, 18 Aug 2002 15:52:23 GMT
jkeyes      2002/08/18 08:52:23

  Modified:    cli/src/test/org/apache/commons/cli BugsTest.java
  Log:
  bug no 11458: added test
  
  Revision  Changes    Path
  1.3       +53 -1     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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BugsTest.java	15 Aug 2002 22:05:19 -0000	1.2
  +++ BugsTest.java	18 Aug 2002 15:52:23 -0000	1.3
  @@ -37,6 +37,58 @@
       {
       }
   
  +    public void test11458()
  +    {
  +        Options options = new Options();
  +        options.addOption( OptionBuilder.withValueSeparator( '=' )
  +                           .hasArgs()
  +                           .create( 'D' ) );
  +        options.addOption( OptionBuilder.withValueSeparator( ':' )
  +                           .hasArgs()
  +                           .create( 'p' ) );
  +        String[] args = new String[] { "-DJAVA_HOME=/opt/java" ,
  +        "-pfile1:file2:file3" };
  +
  +        CommandLineParser parser = CommandLineParserFactory.newParser();
  +
  +        try {
  +            CommandLine cmd = parser.parse( options, args );
  +
  +            String[] values = cmd.getOptionValues( 'D' );
  +
  +            assertEquals( values[0], "JAVA_HOME" );
  +            assertEquals( values[1], "/opt/java" );
  +
  +            values = cmd.getOptionValues( 'p' );
  +
  +            assertEquals( values[0], "file1" );
  +            assertEquals( values[1], "file2" );
  +            assertEquals( values[2], "file3" );
  +
  +            java.util.Iterator iter = cmd.iterator();
  +            while( iter.hasNext() ) {
  +                Option opt = (Option)iter.next();
  +                switch( opt.getId() ) {
  +                    case 'D':
  +                        assertEquals( opt.getValue( 0 ), "JAVA_HOME" );
  +                        assertEquals( opt.getValue( 1 ), "/opt/java" );
  +                        break;
  +                    case 'p':
  +                        assertEquals( opt.getValue( 0 ), "file1" );
  +                        assertEquals( opt.getValue( 1 ), "file2" );
  +                        assertEquals( opt.getValue( 2 ), "file3" );
  +                        break;
  +                    default:
  +                        fail( "-D option not found" );
  +                }
  +            }
  +        }
  +        catch( ParseException exp ) {
  +            fail( "Unexpected Exception:\nMessage:" + exp.getMessage() 
  +                  + "Type: " + exp.getClass().getName() );
  +        }
  +    }
  +
       public void test11680()
       {
           Options options = new Options();
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message