commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r661820 - in /commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli: ValueTest.java ValuesTest.java
Date Fri, 30 May 2008 19:10:27 GMT
Author: ebourg
Date: Fri May 30 12:10:27 2008
New Revision: 661820

URL: http://svn.apache.org/viewvc?rev=661820&view=rev
Log:
Removed fail() in catch blocks in ValueTest and ValuesTest

Modified:
    commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValueTest.java
    commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValuesTest.java

Modified: commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValueTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValueTest.java?rev=661820&r1=661819&r2=661820&view=diff
==============================================================================
--- commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValueTest.java (original)
+++ commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValueTest.java Fri
May 30 12:10:27 2008
@@ -27,49 +27,20 @@
     private CommandLine _cl = null;
     private Options opts = new Options();
 
-    public void setUp()
+    public void setUp() throws Exception
     {
-        opts.addOption("a",
-                       false,
-                       "toggle -a");
-
-        opts.addOption("b",
-                       true,
-                       "set -b");
-
-        opts.addOption("c",
-                       "c",
-                       false,
-                       "toggle -c");
-
-        opts.addOption("d",
-                       "d",
-                       true,
-                       "set -d");
-
-        opts.addOption( OptionBuilder.hasOptionalArg()
-                        .create( 'e') );
-
-        opts.addOption( OptionBuilder.hasOptionalArg()
-                        .withLongOpt( "fish" )
-                        .create( ) );
-
-        opts.addOption( OptionBuilder.hasOptionalArgs()
-                        .withLongOpt( "gravy" )
-                        .create( ) );
-
-        opts.addOption( OptionBuilder.hasOptionalArgs( 2 )
-                        .withLongOpt( "hide" )
-                        .create( ) );
-
-        opts.addOption( OptionBuilder.hasOptionalArgs( 2 )
-                        .create( 'i' ) );
-
-        opts.addOption( OptionBuilder.hasOptionalArgs( )
-                        .create( 'j' ) );
-
-        opts.addOption( OptionBuilder.hasArgs( ).withValueSeparator( ',' )
-                        .create( 'k' ) );
+        opts.addOption("a", false, "toggle -a");
+        opts.addOption("b", true, "set -b");
+        opts.addOption("c", "c", false, "toggle -c");
+        opts.addOption("d", "d", true, "set -d");
+
+        opts.addOption(OptionBuilder.hasOptionalArg().create('e'));
+        opts.addOption(OptionBuilder.hasOptionalArg().withLongOpt("fish").create());
+        opts.addOption(OptionBuilder.hasOptionalArgs().withLongOpt("gravy").create());
+        opts.addOption(OptionBuilder.hasOptionalArgs(2).withLongOpt("hide").create());
+        opts.addOption(OptionBuilder.hasOptionalArgs(2).create('i'));
+        opts.addOption(OptionBuilder.hasOptionalArgs().create('j'));
+        opts.addOption(OptionBuilder.hasArgs().withValueSeparator(',').create('k'));
 
         String[] args = new String[] { "-a",
             "-b", "foo",
@@ -77,15 +48,8 @@
             "--d", "bar" 
         };
 
-        try
-        {
-            Parser parser = new PosixParser();
-            _cl = parser.parse(opts,args);
-        }
-        catch (ParseException e)
-        {
-            fail("Cannot setUp() CommandLine: " + e.toString());
-        }
+        Parser parser = new PosixParser();
+        _cl = parser.parse(opts,args);
     }
 
     public void testShortNoArg()

Modified: commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValuesTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValuesTest.java?rev=661820&r1=661819&r2=661820&view=diff
==============================================================================
--- commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValuesTest.java (original)
+++ commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValuesTest.java Fri
May 30 12:10:27 2008
@@ -25,39 +25,22 @@
 {
     /** CommandLine instance */
     private CommandLine _cmdline = null;
-    private Option _option = null;
 
-    public void setUp()
+    public void setUp() throws Exception
     {
         Options opts = new Options();
 
-        opts.addOption("a",
-                       false,
-                       "toggle -a");
-
-        opts.addOption("b",
-                       true,
-                       "set -b");
-
-        opts.addOption("c",
-                       "c",
-                       false,
-                       "toggle -c");
-
-        opts.addOption("d",
-                       "d",
-                       true,
-                       "set -d");
+        opts.addOption("a", false, "toggle -a");
+        opts.addOption("b", true, "set -b");
+        opts.addOption("c", "c", false, "toggle -c");
+        opts.addOption("d", "d", true, "set -d");
         
         opts.addOption( OptionBuilder.withLongOpt( "e" )
                                      .hasArgs()
                                      .withDescription( "set -e ")
                                      .create( 'e' ) );
 
-        opts.addOption("f",
-                       "f",
-                       false,
-                       "jk");
+        opts.addOption("f", "f", false, "jk");
         
         opts.addOption( OptionBuilder.withLongOpt( "g" )
                         .hasArgs( 2 )
@@ -85,14 +68,12 @@
                         .withValueSeparator( '=' )
                         .create( 'k' ) );
 
-        _option = OptionBuilder.withLongOpt( "m" )
+        opts.addOption( OptionBuilder.withLongOpt( "m" )
                         .hasArgs( )
                         .withDescription( "set -m")
                         .withValueSeparator( )
-                        .create( 'm' );
+                        .create( 'm' ) );
 
-        opts.addOption( _option );
-        
         String[] args = new String[] { "-a",
                                        "-b", "foo",
                                        "--c",
@@ -111,14 +92,7 @@
 
         CommandLineParser parser = new PosixParser();
 
-        try
-        {
-            _cmdline = parser.parse(opts,args);
-        }
-        catch (ParseException e)
-        {
-            fail("Cannot setUp() CommandLine: " + e.toString());
-        }
+        _cmdline = parser.parse(opts,args);
     }
 
     public void testShortArgs()



Mime
View raw message