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-sandbox/cli/src/java/org/apache/commons/cli2 PropertyOption.java
Date Thu, 23 Oct 2003 08:34:45 GMT
roxspring    2003/10/23 01:34:45

  Modified:    cli/src/test/org/apache/commons/cli2 PropertyOptionTest.java
               cli/src/java/org/apache/commons/cli2 PropertyOption.java
  Log:
  PropertyOptions now process arguments such as -Dmyprop as if they were -Dmyprop=true.
  Tests adjusted accordingly
  
  Revision  Changes    Path
  1.3       +6 -9      jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/PropertyOptionTest.java
  
  Index: PropertyOptionTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/PropertyOptionTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PropertyOptionTest.java	22 Oct 2003 16:32:14 -0000	1.2
  +++ PropertyOptionTest.java	23 Oct 2003 08:34:45 -0000	1.3
  @@ -144,12 +144,9 @@
   		final CommandLine commandLine = commandLine(option, args);
   		final ListIterator iterator = args.listIterator();
   
  -		try {
  -			option.process(commandLine, iterator);
  -			fail("No = sign!!");
  -		} catch (final BadPropertyException bpe) {
  -			assertEquals(option, bpe.getOption());
  -		}
  +		option.process(commandLine, iterator);
  +		
  +        assertEquals("true",commandLine.getProperty("myprop"));
   	}
   
   	public void testProcess_SetToEmpty() throws OptionException {
  
  
  
  1.2       +12 -8     jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/PropertyOption.java
  
  Index: PropertyOption.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/cli/src/java/org/apache/commons/cli2/PropertyOption.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PropertyOption.java	18 Oct 2003 22:00:15 -0000	1.1
  +++ PropertyOption.java	23 Oct 2003 08:34:45 -0000	1.2
  @@ -123,15 +123,19 @@
   		if (!canProcess(arg)) {
   			throw new UnexpectedOptionException(this, arg);
   		}
  +        
   		final int propertyStart = optionString.length();
   		final int equalsIndex = arg.indexOf('=', propertyStart);
  -		if (equalsIndex < 0) {
  -			throw new BadPropertyException(this, arg);
  +        final String property;
  +        final String value;
  +        if (equalsIndex < 0) {
  +            property = arg.substring(propertyStart);
  +            value = "true";
   		} else {
  -			final String property = arg.substring(propertyStart, equalsIndex);
  -			final String value = arg.substring(equalsIndex + 1);
  -			commandLine.addProperty(property, value);
  +			property = arg.substring(propertyStart, equalsIndex);
  +			value = arg.substring(equalsIndex + 1);
   		}
  +        commandLine.addProperty(property, value);
   	}
   
   	/* (non-Javadoc)
  
  
  

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