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 ApplicationTest.java GnuParseTest.java
Date Thu, 25 Jul 2002 21:40:08 GMT
jkeyes      2002/07/25 14:40:08

  Modified:    cli/src/java/org/apache/commons/cli
                        CommandLineParserFactory.java
               cli/src/test/org/apache/commons/cli ApplicationTest.java
                        GnuParseTest.java
  Log:
  create the parser using a classname parameter instead of a system property
  
  Revision  Changes    Path
  1.2       +8 -5      jakarta-commons/cli/src/java/org/apache/commons/cli/CommandLineParserFactory.java
  
  Index: CommandLineParserFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/CommandLineParserFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CommandLineParserFactory.java	4 Jul 2002 22:32:12 -0000	1.1
  +++ CommandLineParserFactory.java	25 Jul 2002 21:40:08 -0000	1.2
  @@ -76,9 +76,12 @@
        * @return the CommandLineParser
        */
       public static CommandLineParser newParser() {
  -        String parserImpl = System.getProperty( "org.apache.commons.cli.parser" );
  +        return newParser( DEFAULT_PARSER );
  +    }
  +
  +    public static CommandLineParser newParser( String classname ) {
           try {
  -            return (CommandLineParser)Class.forName( parserImpl ).newInstance();
  +            return (CommandLineParser)Class.forName( classname ).newInstance();
           }
           catch( Exception exp ) {
               // could not create according to parserImpl so default to
  
  
  
  1.4       +1 -4      jakarta-commons/cli/src/test/org/apache/commons/cli/ApplicationTest.java
  
  Index: ApplicationTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/ApplicationTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ApplicationTest.java	4 Jul 2002 22:32:12 -0000	1.3
  +++ ApplicationTest.java	25 Jul 2002 21:40:08 -0000	1.4
  @@ -35,10 +35,7 @@
        */
       public void testAnt() {
           // use the GNU parser
  -        System.setProperty( "org.apache.commons.cli.parser",
  -                            "org.apache.commons.cli.GnuParser");
  -
  -        CommandLineParser parser = CommandLineParserFactory.newParser();
  +        CommandLineParser parser = CommandLineParserFactory.newParser( "org.apache.commons.cli.GnuParser"
);
           Options options = new Options();
           options.addOption( "help", false, "print this message" );
           options.addOption( "projecthelp", false, "print project help information" );
  
  
  
  1.2       +2 -5      jakarta-commons/cli/src/test/org/apache/commons/cli/GnuParseTest.java
  
  Index: GnuParseTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli/GnuParseTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GnuParseTest.java	4 Jul 2002 22:32:12 -0000	1.1
  +++ GnuParseTest.java	25 Jul 2002 21:40:08 -0000	1.2
  @@ -30,9 +30,6 @@
   
       public void setUp()
       {
  -        System.setProperty( "org.apache.commons.cli.parser",
  -                            "org.apache.commons.cli.GnuParser");
  -
           _options = new Options()
               .addOption("a",
                          "enable-a",
  @@ -47,7 +44,7 @@
                          false,
                          "turn [c] on or off");
   
  -        _parser = CommandLineParserFactory.newParser();
  +        _parser = CommandLineParserFactory.newParser( "org.apache.commons.cli.GnuParser"
);
       }
   
       public void tearDown()
  
  
  

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