commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline CommandLineImpl.java
Date Sat, 27 Mar 2004 00:17:46 GMT
roxspring    2004/03/26 16:17:46

  Modified:    cli/src/test/org/apache/commons/cli2/commandline Tag:
                        RESEARCH_CLI_2_ROXSPRING
                        DefaultingCommandLineTest.java
               cli/src/test/org/apache/commons/cli2 Tag:
                        RESEARCH_CLI_2_ROXSPRING
                        WriteableCommandLineTestCase.java
                        CommandLineTestCase.java
               cli/src/java/org/apache/commons/cli2/commandline Tag:
                        RESEARCH_CLI_2_ROXSPRING CommandLineImpl.java
  Log:
  Minor changes to make the CommandLine implementation and tests appropriate to PropertiesCommandLine
(more shortly)
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.1.2.3   +1 -1      jakarta-commons/cli/src/test/org/apache/commons/cli2/commandline/Attic/DefaultingCommandLineTest.java
  
  Index: DefaultingCommandLineTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/commandline/Attic/DefaultingCommandLineTest.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- DefaultingCommandLineTest.java	3 Mar 2004 01:10:19 -0000	1.1.2.2
  +++ DefaultingCommandLineTest.java	27 Mar 2004 00:17:46 -0000	1.1.2.3
  @@ -48,7 +48,7 @@
   		final WriteableCommandLine writeable = new WriteableCommandLineImpl(root,new ArrayList());
   		writeable.addOption(present);
   		writeable.addProperty("present","present property");
  -		writeable.addSwitch(present,true);
  +		writeable.addSwitch(bool,true);
   		writeable.addValue(present,"present value");
   		writeable.addOption(multiple);
   		writeable.addValue(multiple,"value 1");
  
  
  
  No                   revision
  No                   revision
  1.1.2.2   +1 -1      jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/WriteableCommandLineTestCase.java
  
  Index: WriteableCommandLineTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/WriteableCommandLineTestCase.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- WriteableCommandLineTestCase.java	3 Mar 2004 01:10:19 -0000	1.1.2.1
  +++ WriteableCommandLineTestCase.java	27 Mar 2004 00:17:46 -0000	1.1.2.2
  @@ -36,7 +36,7 @@
   		final WriteableCommandLine writeable = createWriteableCommandLine();
   		writeable.addOption(present);
   		writeable.addProperty("present","present property");
  -		writeable.addSwitch(present,true);
  +		writeable.addSwitch(bool,true);
   		writeable.addValue(present,"present value");
   		writeable.addOption(multiple);
   		writeable.addValue(multiple,"value 1");
  
  
  
  1.1.2.2   +15 -13    jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/CommandLineTestCase.java
  
  Index: CommandLineTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/test/org/apache/commons/cli2/Attic/CommandLineTestCase.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CommandLineTestCase.java	3 Mar 2004 01:10:19 -0000	1.1.2.1
  +++ CommandLineTestCase.java	27 Mar 2004 00:17:46 -0000	1.1.2.2
  @@ -36,8 +36,9 @@
   	public final Option present = new DefaultOptionBuilder().withLongName("present").withLongName("alsopresent").create();
   	public final Option missing = new DefaultOptionBuilder().withLongName("missing").create();
   	public final Option multiple = new DefaultOptionBuilder().withLongName("multiple").create();
  +	public final Option bool = new DefaultOptionBuilder().withLongName("bool").create();
   	
  -	public final Option root = new GroupBuilder().withOption(present).withOption(missing).withOption(multiple).create();
  +	public final Option root = new GroupBuilder().withOption(present).withOption(missing).withOption(multiple).withOption(bool).create();
   	
   	private CommandLine commandLine;
   	
  @@ -75,6 +76,8 @@
   	 */
   	public final void testGetValuesString() {
   		assertListContentsEqual(list("present value"),commandLine.getValues("--present"));
  +		System.out.println(commandLine.getValues("--multiple"));
  +		assertListContentsEqual(list("value 1","value 2","value 3"),commandLine.getValues("--multiple"));
   		assertTrue(commandLine.getValues("--missing").isEmpty());
   	}
   	/*
  @@ -83,7 +86,7 @@
   	public final void testGetValuesStringList() {
   		assertListContentsEqual(list("present value"),commandLine.getValues("--present",null));
   		assertListContentsEqual(list("present value"),commandLine.getValues("--alsopresent",null));
  -		assertTrue(commandLine.getValues("--missing",null).isEmpty());
  +		assertSame(commandLine.getValues("--missing",Collections.EMPTY_LIST),Collections.EMPTY_LIST);
   		final List def = Collections.singletonList("default value");
   		assertSame(def,commandLine.getValues("--missing",def));
   	}
  @@ -99,7 +102,7 @@
   	 */
   	public final void testGetValuesOptionList() {
   		assertListContentsEqual(list("present value"),commandLine.getValues(present));
  -		assertTrue(commandLine.getValues(missing,null).isEmpty());
  +		assertSame(commandLine.getValues(missing,Collections.EMPTY_LIST),Collections.EMPTY_LIST);
   		final List defs = Collections.singletonList("custom default");
   		assertSame(defs,commandLine.getValues(missing,defs));
   	}
  @@ -165,30 +168,28 @@
   	 * Class to test for Boolean getSwitch(String)
   	 */
   	public final void testGetSwitchString() {
  -		assertEquals(Boolean.TRUE,commandLine.getSwitch("--present"));
  -		assertEquals(Boolean.TRUE,commandLine.getSwitch("--alsopresent"));
  +		assertEquals(Boolean.TRUE,commandLine.getSwitch("--bool"));
   		assertNull(commandLine.getSwitch("--missing"));
   	}
   	/*
   	 * Class to test for Boolean getSwitch(String, Boolean)
   	 */
   	public final void testGetSwitchStringBoolean() {
  -		assertEquals(Boolean.TRUE,commandLine.getSwitch("--present",Boolean.FALSE));
  -		assertEquals(Boolean.TRUE,commandLine.getSwitch("--alsopresent",Boolean.FALSE));
  +		assertEquals(Boolean.TRUE,commandLine.getSwitch("--bool",Boolean.FALSE));
   		assertEquals(Boolean.FALSE,commandLine.getSwitch("--missing",Boolean.FALSE));
   	}
   	/*
   	 * Class to test for Boolean getSwitch(Option)
   	 */
   	public final void testGetSwitchOption() {
  -		assertEquals(Boolean.TRUE,commandLine.getSwitch(present));
  +		assertEquals(Boolean.TRUE,commandLine.getSwitch(bool));
   		assertNull(commandLine.getSwitch(missing));
   	}
   	/*
   	 * Class to test for Boolean getSwitch(Option, Boolean)
   	 */
   	public final void testGetSwitchOptionBoolean() {
  -		assertEquals(Boolean.TRUE,commandLine.getSwitch(present,Boolean.FALSE));
  +		assertEquals(Boolean.TRUE,commandLine.getSwitch(bool,Boolean.FALSE));
   		assertEquals(Boolean.FALSE,commandLine.getSwitch(missing,Boolean.FALSE));
   	}
   	/*
  @@ -206,15 +207,15 @@
   		assertEquals("default property",commandLine.getProperty("missing","default property"));
   	}
   	public final void testGetProperties() {
  -		assertContentsEqual(list("present"),commandLine.getProperties());
  +		assertTrue(commandLine.getProperties().containsAll(list("present")));
   	}
   	/*
   	 * Class to test for int getOptionCount(String)
   	 */
   	public final void testGetOptionCountString() {
   		// one option, one switch
  -		assertEquals(2,commandLine.getOptionCount("--present"));
  -		assertEquals(2,commandLine.getOptionCount("--alsopresent"));
  +		assertTrue(1<=commandLine.getOptionCount("--present"));
  +		assertTrue(1<=commandLine.getOptionCount("--bool"));
   		assertEquals(0,commandLine.getOptionCount("--missing"));
   	}
   	/*
  @@ -222,7 +223,8 @@
   	 */
   	public final void testGetOptionCountOption() {
   		// one option, one switch
  -		assertEquals(2,commandLine.getOptionCount(present));
  +		assertTrue(1<=commandLine.getOptionCount(present));
  +		assertTrue(1<=commandLine.getOptionCount(bool));
   		assertEquals(0,commandLine.getOptionCount(missing));
   	}
   	public final void testGetOptions() {
  
  
  
  No                   revision
  No                   revision
  1.1.2.7   +3 -3      jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java
  
  Index: CommandLineImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli2/commandline/Attic/CommandLineImpl.java,v
  retrieving revision 1.1.2.6
  retrieving revision 1.1.2.7
  diff -u -r1.1.2.6 -r1.1.2.7
  --- CommandLineImpl.java	25 Feb 2004 00:36:30 -0000	1.1.2.6
  +++ CommandLineImpl.java	27 Mar 2004 00:17:46 -0000	1.1.2.7
  @@ -35,7 +35,7 @@
       }
   
       public final List getValues(final String trigger) {
  -        return getValues(getOption(trigger),null);
  +        return getValues(getOption(trigger),Collections.EMPTY_LIST);
       }
   
       public final List getValues(final String trigger, final List defaultValues) {
  @@ -43,7 +43,7 @@
       }
   
       public final List getValues(final Option option) {
  -        return getValues(option, null);
  +        return getValues(option, Collections.EMPTY_LIST);
       }
   
       public final Object getValue(final String trigger) {
  @@ -62,7 +62,7 @@
   
           final List values;
           if (defaultValue == null) {
  -            values = getValues(option, null);
  +            values = getValues(option);
           }
           else {
               values = getValues(option, Collections.singletonList(defaultValue));
  
  
  

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


Mime
View raw message