Author: ebourg
Date: Mon Jun 2 12:49:00 2008
New Revision: 662534
URL: http://svn.apache.org/viewvc?rev=662534&view=rev
Log:
Changed the assertions checking the number of values in ValuesTest to use
assertEquals instead of assertTrue
Modified:
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/ValuesTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/ValuesTest.java?rev=662534&r1=662533&r2=662534&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
Mon Jun 2 12:49:00 2008
@@ -28,51 +28,21 @@
public void setUp() throws Exception
{
- Options opts = new Options();
+ Options options = 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( OptionBuilder.withLongOpt( "e" )
- .hasArgs()
- .withDescription( "set -e ")
- .create( 'e' ) );
-
- opts.addOption("f", "f", false, "jk");
-
- opts.addOption( OptionBuilder.withLongOpt( "g" )
- .hasArgs( 2 )
- .withDescription( "set -g")
- .create( 'g' ) );
-
- opts.addOption( OptionBuilder.withLongOpt( "h" )
- .hasArgs( 2 )
- .withDescription( "set -h")
- .create( 'h' ) );
-
- opts.addOption( OptionBuilder.withLongOpt( "i" )
- .withDescription( "set -i")
- .create( 'i' ) );
-
- opts.addOption( OptionBuilder.withLongOpt( "j" )
- .hasArgs( )
- .withDescription( "set -j")
- .withValueSeparator( '=' )
- .create( 'j' ) );
-
- opts.addOption( OptionBuilder.withLongOpt( "k" )
- .hasArgs( )
- .withDescription( "set -k")
- .withValueSeparator( '=' )
- .create( 'k' ) );
-
- opts.addOption( OptionBuilder.withLongOpt( "m" )
- .hasArgs( )
- .withDescription( "set -m")
- .withValueSeparator( )
- .create( 'm' ) );
+ options.addOption("a", false, "toggle -a");
+ options.addOption("b", true, "set -b");
+ options.addOption("c", "c", false, "toggle -c");
+ options.addOption("d", "d", true, "set -d");
+
+
options.addOption(OptionBuilder.withLongOpt("e").hasArgs().withDescription("set
-e ").create('e'));
+ options.addOption("f", "f", false, "jk");
+
options.addOption(OptionBuilder.withLongOpt("g").hasArgs(2).withDescription("set
-g").create('g'));
+
options.addOption(OptionBuilder.withLongOpt("h").hasArgs(2).withDescription("set
-h").create('h'));
+ options.addOption(OptionBuilder.withLongOpt("i").withDescription("set
-i").create('i'));
+
options.addOption(OptionBuilder.withLongOpt("j").hasArgs().withDescription("set
-j").withValueSeparator('=').create('j'));
+
options.addOption(OptionBuilder.withLongOpt("k").hasArgs().withDescription("set
-k").withValueSeparator('=').create('k'));
+
options.addOption(OptionBuilder.withLongOpt("m").hasArgs().withDescription("set
-m").withValueSeparator().create('m'));
String[] args = new String[] { "-a",
"-b", "foo",
@@ -92,7 +62,7 @@
CommandLineParser parser = new PosixParser();
- _cmdline = parser.parse(opts,args);
+ _cmdline = parser.parse(options,args);
}
public void testShortArgs()
@@ -108,11 +78,11 @@
{
assertTrue( _cmdline.hasOption("b") );
assertTrue( _cmdline.getOptionValue("b").equals("foo"));
- assertTrue( _cmdline.getOptionValues("b").length == 1);
+ assertEquals(1, _cmdline.getOptionValues("b").length);
assertTrue( _cmdline.hasOption("d") );
assertTrue( _cmdline.getOptionValue("d").equals("bar"));
- assertTrue( _cmdline.getOptionValues("d").length == 1);
+ assertEquals(1, _cmdline.getOptionValues("d").length);
}
public void testMultipleArgValues()
@@ -120,7 +90,7 @@
String[] result = _cmdline.getOptionValues("e");
String[] values = new String[] { "one", "two" };
assertTrue( _cmdline.hasOption("e") );
- assertTrue( _cmdline.getOptionValues("e").length == 2);
+ assertEquals(2, _cmdline.getOptionValues("e").length);
assertTrue( Arrays.equals( values, _cmdline.getOptionValues("e") ) );
}
@@ -129,7 +99,7 @@
String[] result = _cmdline.getOptionValues("g");
String[] values = new String[] { "val1", "val2" };
assertTrue( _cmdline.hasOption("g") );
- assertTrue( _cmdline.getOptionValues("g").length == 2);
+ assertEquals(2, _cmdline.getOptionValues("g").length);
assertTrue( Arrays.equals( values, _cmdline.getOptionValues("g") ) );
}
@@ -139,14 +109,14 @@
String[] values = new String[] { "val1", "val2" };
assertTrue( _cmdline.hasOption("i") );
assertTrue( _cmdline.hasOption("h") );
- assertTrue( _cmdline.getOptionValues("h").length == 2);
+ assertEquals(2, _cmdline.getOptionValues("h").length);
assertTrue( Arrays.equals( values, _cmdline.getOptionValues("h") ) );
}
public void testExtraArgs()
{
String[] args = new String[] { "arg1", "arg2", "arg3" };
- assertTrue( _cmdline.getArgs().length == 3 );
+ assertEquals(3, _cmdline.getArgs().length);
assertTrue( Arrays.equals( args, _cmdline.getArgs() ) );
}
@@ -165,16 +135,16 @@
values = new String[] { "key1", "value1", "key2", "value2" };
assertTrue( _cmdline.hasOption( "k" ) );
assertTrue( _cmdline.hasOption( 'k' ) );
- assertTrue( _cmdline.getOptionValues( "k" ).length == 4 );
- assertTrue( _cmdline.getOptionValues( 'k' ).length == 4 );
+ assertEquals(4, _cmdline.getOptionValues( "k" ).length);
+ assertEquals(4, _cmdline.getOptionValues( 'k' ).length);
assertTrue( Arrays.equals( values, _cmdline.getOptionValues( "k" ) ) );
assertTrue( Arrays.equals( values, _cmdline.getOptionValues( 'k' ) ) );
values = new String[] { "key", "value" };
assertTrue( _cmdline.hasOption( "m" ) );
assertTrue( _cmdline.hasOption( 'm' ) );
- assertTrue( _cmdline.getOptionValues( "m" ).length == 2);
- assertTrue( _cmdline.getOptionValues( 'm' ).length == 2);
+ assertEquals(2, _cmdline.getOptionValues( "m" ).length);
+ assertEquals(2, _cmdline.getOptionValues( 'm' ).length);
assertTrue( Arrays.equals( values, _cmdline.getOptionValues( "m" ) ) );
assertTrue( Arrays.equals( values, _cmdline.getOptionValues( 'm' ) ) );
}