commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r661816 - in /commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli: GnuParseTest.java GnuParserTest.java
Date Fri, 30 May 2008 18:59:38 GMT
Author: ebourg
Date: Fri May 30 11:59:37 2008
New Revision: 661816

URL: http://svn.apache.org/viewvc?rev=661816&view=rev
Log:
Renamed GnuParseTest into GnuParserTest + style reformatting

Added:
    commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
  (contents, props changed)
      - copied, changed from r661807, commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParseTest.java
Removed:
    commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParseTest.java

Copied: commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
(from r661807, commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParseTest.java)
URL: http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java?p2=commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java&p1=commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParseTest.java&r1=661807&r2=661816&rev=661816&view=diff
==============================================================================
--- commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParseTest.java
(original)
+++ commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
Fri May 30 11:59:37 2008
@@ -19,28 +19,19 @@
 
 import junit.framework.TestCase;
 
-public class GnuParseTest extends TestCase
+public class GnuParserTest extends TestCase
 {
-    private Options _options = null;
-    private Parser _parser = null;
+    private Options options;
+    private Parser parser;
 
     public void setUp()
     {
-        _options = new Options()
-            .addOption("a",
-                       "enable-a",
-                       false,
-                       "turn [a] on or off")
-            .addOption("b",
-                       "bfile",
-                       true,
-                       "set the value of [b]")
-            .addOption("c",
-                       "copt",
-                       false,
-                       "turn [c] on or off");
+        options = new Options()
+            .addOption("a", "enable-a", false, "turn [a] on or off")
+            .addOption("b", "bfile", true, "set the value of [b]")
+            .addOption("c", "copt", false, "turn [c] on or off");
 
-        _parser = new GnuParser( );
+        parser = new GnuParser( );
     }
 
     public void testSimpleShort() throws Exception
@@ -49,12 +40,12 @@
                                        "-b", "toast",
                                        "foo", "bar" };
 
-        CommandLine cl = _parser.parse(_options, args);
+        CommandLine cl = parser.parse(options, args);
 
-        assertTrue( "Confirm -a is set", cl.hasOption("a") );
-        assertTrue( "Confirm -b is set", cl.hasOption("b") );
-        assertTrue( "Confirm arg of -b", cl.getOptionValue("b").equals("toast") );
-        assertTrue( "Confirm size of extra args", cl.getArgList().size() == 2);
+        assertTrue("Confirm -a is set", cl.hasOption("a"));
+        assertTrue("Confirm -b is set", cl.hasOption("b"));
+        assertTrue("Confirm arg of -b", cl.getOptionValue("b").equals("toast"));
+        assertTrue("Confirm size of extra args", cl.getArgList().size() == 2);
     }
 
     public void testSimpleLong() throws Exception
@@ -63,12 +54,12 @@
                                        "--bfile", "toast",
                                        "foo", "bar" };
 
-        CommandLine cl = _parser.parse(_options, args);
+        CommandLine cl = parser.parse(options, args);
 
-        assertTrue( "Confirm -a is set", cl.hasOption("a") );
-        assertTrue( "Confirm -b is set", cl.hasOption("b") );
-        assertTrue( "Confirm arg of -b", cl.getOptionValue("b").equals("toast") );
-        assertTrue( "Confirm size of extra args", cl.getArgList().size() == 2);
+        assertTrue("Confirm -a is set", cl.hasOption("a"));
+        assertTrue("Confirm -b is set", cl.hasOption("b"));
+        assertTrue("Confirm arg of -b", cl.getOptionValue("b").equals("toast"));
+        assertTrue("Confirm size of extra args", cl.getArgList().size() == 2);
     }
 
     public void testExtraOption() throws Exception
@@ -80,12 +71,12 @@
 
         try
         {
-            CommandLine cl = _parser.parse(_options, args);
-            
-            assertTrue( "Confirm -a is set", cl.hasOption("a") );
-            assertTrue( "Confirm -b is set", cl.hasOption("b") );
-            assertTrue( "confirm arg of -b", cl.getOptionValue("b").equals("toast") );
-            assertTrue( "Confirm size of extra args", cl.getArgList().size() == 3);
+            CommandLine cl = parser.parse(options, args);
+
+            assertTrue("Confirm -a is set", cl.hasOption("a"));
+            assertTrue("Confirm -b is set", cl.hasOption("b"));
+            assertTrue("confirm arg of -b", cl.getOptionValue("b").equals("toast"));
+            assertTrue("Confirm size of extra args", cl.getArgList().size() == 3);
         }
         catch (UnrecognizedOptionException e)
         {
@@ -103,7 +94,7 @@
 
         try
         {
-            _parser.parse(_options, args);
+            parser.parse(options, args);
         }
         catch (MissingArgumentException e)
         {
@@ -120,9 +111,9 @@
                                        "-b",
                                        "toast" };
 
-        CommandLine cl = _parser.parse(_options, args, true);
-        assertTrue( "Confirm -c is set", cl.hasOption("c") );
-        assertTrue( "Confirm  3 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 3);
+        CommandLine cl = parser.parse(options, args, true);
+        assertTrue("Confirm -c is set", cl.hasOption("c"));
+        assertTrue("Confirm  3 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 3);
     }
 
     public void testMultiple() throws Exception
@@ -132,17 +123,17 @@
                                        "-b",
                                        "toast" };
 
-        CommandLine cl = _parser.parse(_options, args, true);
-        assertTrue( "Confirm -c is set", cl.hasOption("c") );
-        assertTrue( "Confirm  3 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 3);
-
-        cl = _parser.parse(_options, cl.getArgs() );
-
-        assertTrue( "Confirm -c is not set", ! cl.hasOption("c") );
-        assertTrue( "Confirm -b is set", cl.hasOption("b") );
-        assertTrue( "Confirm arg of -b", cl.getOptionValue("b").equals("toast") );
-        assertTrue( "Confirm  1 extra arg: " + cl.getArgList().size(), cl.getArgList().size()
== 1);
-        assertTrue( "Confirm  value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("foobar")
);
+        CommandLine cl = parser.parse(options, args, true);
+        assertTrue("Confirm -c is set", cl.hasOption("c"));
+        assertTrue("Confirm  3 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 3);
+
+        cl = parser.parse(options, cl.getArgs());
+
+        assertTrue("Confirm -c is not set", !cl.hasOption("c"));
+        assertTrue("Confirm -b is set", cl.hasOption("b"));
+        assertTrue("Confirm arg of -b", cl.getOptionValue("b").equals("toast"));
+        assertTrue("Confirm  1 extra arg: " + cl.getArgList().size(), cl.getArgList().size()
== 1);
+        assertTrue("Confirm  value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("foobar"));
     }
 
     public void testMultipleWithLong() throws Exception
@@ -151,18 +142,17 @@
                                        "foobar",
                                        "--bfile", "toast" };
 
-        CommandLine cl = _parser.parse(_options,args,
-                                        true);
-        assertTrue( "Confirm -c is set", cl.hasOption("c") );
-        assertTrue( "Confirm  3 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 3);
-
-        cl = _parser.parse(_options, cl.getArgs() );
-
-        assertTrue( "Confirm -c is not set", ! cl.hasOption("c") );
-        assertTrue( "Confirm -b is set", cl.hasOption("b") );
-        assertTrue( "Confirm arg of -b", cl.getOptionValue("b").equals("toast") );
-        assertTrue( "Confirm  1 extra arg: " + cl.getArgList().size(), cl.getArgList().size()
== 1);
-        assertTrue( "Confirm  value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("foobar")
);
+        CommandLine cl = parser.parse(options,args, true);
+        assertTrue("Confirm -c is set", cl.hasOption("c"));
+        assertTrue("Confirm  3 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 3);
+
+        cl = parser.parse(options, cl.getArgs());
+
+        assertTrue("Confirm -c is not set", !cl.hasOption("c"));
+        assertTrue("Confirm -b is set", cl.hasOption("b"));
+        assertTrue("Confirm arg of -b", cl.getOptionValue("b").equals("toast"));
+        assertTrue("Confirm  1 extra arg: " + cl.getArgList().size(), cl.getArgList().size()
== 1);
+        assertTrue("Confirm  value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("foobar"));
     }
 
     public void testDoubleDash() throws Exception
@@ -171,11 +161,11 @@
                                        "--",
                                        "-b", "toast" };
 
-        CommandLine cl = _parser.parse(_options, args);
+        CommandLine cl = parser.parse(options, args);
 
-        assertTrue( "Confirm -c is set", cl.hasOption("c") );
-        assertTrue( "Confirm -b is not set", ! cl.hasOption("b") );
-        assertTrue( "Confirm 2 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 2);
+        assertTrue("Confirm -c is set", cl.hasOption("c"));
+        assertTrue("Confirm -b is not set", !cl.hasOption("b"));
+        assertTrue("Confirm 2 extra args: " + cl.getArgList().size(), cl.getArgList().size()
== 2);
     }
 
     public void testSingleDash() throws Exception
@@ -185,13 +175,13 @@
                                        "-a",
                                        "-" };
 
-        CommandLine cl = _parser.parse(_options, args);
+        CommandLine cl = parser.parse(options, args);
 
-        assertTrue( "Confirm -a is set", cl.hasOption("a") );
-        assertTrue( "Confirm -b is set", cl.hasOption("b") );
-        assertTrue( "Confirm arg of -b", cl.getOptionValue("b").equals("-") );
-        assertTrue( "Confirm 1 extra arg: " + cl.getArgList().size(), cl.getArgList().size()
== 1);
-        assertTrue( "Confirm value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("-")
);
+        assertTrue("Confirm -a is set", cl.hasOption("a"));
+        assertTrue("Confirm -b is set", cl.hasOption("b"));
+        assertTrue("Confirm arg of -b", cl.getOptionValue("b").equals("-"));
+        assertTrue("Confirm 1 extra arg: " + cl.getArgList().size(), cl.getArgList().size()
== 1);
+        assertTrue("Confirm value of extra arg: " + cl.getArgList().get(0), cl.getArgList().get(0).equals("-"));
     }
 
     public void testNegativeArgument() throws Exception

Propchange: commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL



Mime
View raw message