commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r678886 - in /commons/proper/cli/trunk/src: java/org/apache/commons/cli2/ java/org/apache/commons/cli2/commandline/ java/org/apache/commons/cli2/option/ test/org/apache/commons/cli2/ test/org/apache/commons/cli2/bug/ test/org/apache/commons...
Date Tue, 22 Jul 2008 20:27:10 GMT
Author: oheger
Date: Tue Jul 22 13:27:09 2008
New Revision: 678886

URL: http://svn.apache.org/viewvc?rev=678886&view=rev
Log:
CLI-126: Applied patch from Brian Egge

Added:
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java   (with
props)
Modified:
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/CommandLineImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/DefaultingCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PreferencesCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PropertiesCommandLine.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java
    commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/WriteableCommandLineTestCase.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI12Test.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/DefaultingCommandLineTest.java
    commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/CommandLine.java Tue Jul 22
13:27:09 2008
@@ -158,7 +158,7 @@
 
 
     /**
-     * Retrieves the value associated with the specified property
+     * Retrieves the value associated with the specified property for the default property
set
      *
      * @param property the property name to lookup
      * @return the value of the property or null
@@ -168,14 +168,32 @@
     /**
      * Retrieves the value associated with the specified property
      *
+     * @param option the option i.e., -D
+     * @param property the property name to lookup
+     * @return the value of the property or null
+     */
+    String getProperty(final Option option, final String property);
+
+    /**
+     * Retrieves the value associated with the specified property
+     *
+     * @param option the option i.e., -D
      * @param property the property name to lookup
      * @param defaultValue the value to use if no other is found
      * @return the value of the property or defaultValue
      */
-    String getProperty(final String property, final String defaultValue);
+    String getProperty(final Option option, final String property, final String defaultValue);
+
+    /**
+     * Retrieves the set of all property names associated with this option
+     *
+     * @param option the option i.e., -D
+     * @return a none null set of property names
+     */
+    Set getProperties(final Option option);
 
     /**
-     * Retrieves the set of all property names associated with this CommandLine
+     * Retrieves the set of all property names associated with the default property option
      *
      * @return a none null set of property names
      */

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/WriteableCommandLine.java Tue
Jul 22 13:27:09 2008
@@ -72,6 +72,16 @@
      * Adds a property value to a name in the CommandLine.
      * Replaces any existing value for the property.
      *
+     * @param option the Option to add to
+     * @param property the name of the property
+     * @param value the value of the property
+     */
+    void addProperty(final Option option, final String property, final String value);
+
+    /**
+     * Adds a property value to the default property set.
+     * Replaces any existing value for the property.
+     *
      * @param property the name of the property
      * @param value the value of the property
      */

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/CommandLineImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/CommandLineImpl.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/CommandLineImpl.java
(original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/CommandLineImpl.java
Tue Jul 22 13:27:09 2008
@@ -94,8 +94,8 @@
         return getSwitch(option, null);
     }
 
-    public final String getProperty(final String property) {
-        return getProperty(property, null);
+    public final String getProperty(final Option option, final String property) {
+        return getProperty(option, property, null);
     }
 
     public final int getOptionCount(final String trigger) {

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/DefaultingCommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/DefaultingCommandLine.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/DefaultingCommandLine.java
(original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/DefaultingCommandLine.java
Tue Jul 22 13:27:09 2008
@@ -25,6 +25,7 @@
 
 import org.apache.commons.cli2.CommandLine;
 import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.option.PropertyOption;
 
 /**
  * Manages a queue of default CommandLines. This CommandLine implementation is
@@ -150,10 +151,14 @@
         return defaultValue;
     }
 
-    public String getProperty(String property, String defaultValue) {
+    public String getProperty(final String property) {
+        return getProperty(new PropertyOption(), property);
+    }
+
+    public String getProperty(final Option option, String property, String defaultValue)
{
         for (final Iterator i = commandLines.iterator(); i.hasNext();) {
             final CommandLine commandLine = (CommandLine)i.next();
-            final String actual = commandLine.getProperty(property);
+            final String actual = commandLine.getProperty(option, property);
             if (actual != null) {
                 return actual;
             }
@@ -161,12 +166,16 @@
         return defaultValue;
     }
 
-    public Set getProperties() {
+    public Set getProperties(final Option option) {
         final Set all = new HashSet();
         for (final Iterator i = commandLines.iterator(); i.hasNext();) {
             final CommandLine commandLine = (CommandLine)i.next();
-            all.addAll(commandLine.getProperties());
+            all.addAll(commandLine.getProperties(option));
         }
         return Collections.unmodifiableSet(all);
     }
+
+    public Set getProperties() {
+        return getProperties(new PropertyOption());
+    }
 }

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PreferencesCommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PreferencesCommandLine.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PreferencesCommandLine.java
(original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PreferencesCommandLine.java
Tue Jul 22 13:27:09 2008
@@ -28,6 +28,7 @@
 import java.util.prefs.Preferences;
 
 import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.option.PropertyOption;
 
 /**
  * A CommandLine implementation using the Preferences API, useful when
@@ -129,11 +130,15 @@
         }
     }
 
-    public String getProperty(final String property, final String defaultValue) {
+    public String getProperty(final String property) {
+        return getProperty(new PropertyOption(), property);
+    }
+
+    public String getProperty(final Option option, final String property, final String defaultValue)
{
         return preferences.get(property, defaultValue);
     }
 
-    public Set getProperties() {
+	public Set getProperties(final Option option) {
         try {
             return new HashSet(Arrays.asList(preferences.keys()));
         } catch (BackingStoreException e) {
@@ -141,6 +146,10 @@
         }
     }
 
+    public Set getProperties() {
+        return getProperties(new PropertyOption());
+    }
+
     public List getOptions() {
         try {
             final List options = new ArrayList();

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PropertiesCommandLine.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PropertiesCommandLine.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PropertiesCommandLine.java
(original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/PropertiesCommandLine.java
Tue Jul 22 13:27:09 2008
@@ -26,6 +26,7 @@
 import java.util.StringTokenizer;
 
 import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.option.PropertyOption;
 
 /**
  * A CommandLine implementation using a java Properties instance, useful for
@@ -122,14 +123,22 @@
         }
     }
 
-    public String getProperty(final String property, final String defaultValue) {
+    public String getProperty(final String property) {
+        return getProperty(new PropertyOption(), property);
+    }
+
+    public String getProperty(final Option option, final String property, final String defaultValue)
{
         return properties.getProperty(property,defaultValue);
     }
 
-    public Set getProperties() {
+	public Set getProperties(final Option option) {
         return properties.keySet();
     }
 
+    public Set getProperties() {
+        return getProperties(new PropertyOption());
+    }
+
     public List getOptions() {
         final List options = new ArrayList();
         final Iterator keys = properties.keySet().iterator();

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java
(original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/WriteableCommandLineImpl.java
Tue Jul 22 13:27:09 2008
@@ -28,6 +28,7 @@
 import org.apache.commons.cli2.Argument;
 import org.apache.commons.cli2.Option;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.option.PropertyOption;
 import org.apache.commons.cli2.resource.ResourceConstants;
 import org.apache.commons.cli2.resource.ResourceHelper;
 
@@ -37,7 +38,8 @@
  */
 public class WriteableCommandLineImpl
     extends CommandLineImpl implements WriteableCommandLine {
-    private final Properties properties = new Properties();
+    private final Map optionToProperties = new HashMap();
+//    private final Properties properties = new Properties();
     private final List options = new ArrayList();
     private final Map nameToOption = new HashMap();
     private final Map values = new HashMap();
@@ -159,20 +161,47 @@
         return bool;
     }
 
-    public void addProperty(final String property,
+    public String getProperty(final String property) {
+        return getProperty(new PropertyOption(), property);
+    }
+
+    public void addProperty(final Option option,
+                            final String property,
                             final String value) {
+        Properties properties = (Properties) optionToProperties.get(option);
+        if (properties == null) {
+            properties = new Properties();
+            optionToProperties.put(option, properties);
+        }
         properties.setProperty(property, value);
     }
 
-    public String getProperty(final String property,
+    public void addProperty(final String property, final String value) {
+        addProperty(new PropertyOption(), property, value);
+    }
+
+    public String getProperty(final Option option,
+                              final String property,
                               final String defaultValue) {
+        Properties properties = (Properties) optionToProperties.get(option);
+        if (properties == null) {
+            return defaultValue;
+        }
         return properties.getProperty(property, defaultValue);
     }
 
-    public Set getProperties() {
+    public Set getProperties(final Option option) {
+        Properties properties = (Properties) optionToProperties.get(option);
+        if (properties == null) {
+            return Collections.EMPTY_SET;
+        }
         return Collections.unmodifiableSet(properties.keySet());
     }
 
+    public Set getProperties() {
+        return getProperties(new PropertyOption());
+    }
+
     public boolean looksLikeOption(final String trigger) {
         for (final Iterator i = prefixes.iterator(); i.hasNext();) {
             final String prefix = (String) i.next();

Modified: commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java (original)
+++ commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java Tue
Jul 22 13:27:09 2008
@@ -100,7 +100,7 @@
             value = arg.substring(equalsIndex + 1);
         }
 
-        commandLine.addProperty(property, value);
+        commandLine.addProperty(this, property, value);
     }
 
     public Set getTriggers() {

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineTestCase.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineTestCase.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/CommandLineTestCase.java Tue
Jul 22 13:27:09 2008
@@ -234,8 +234,8 @@
      * Class to test for String getProperty(String, String)
      */
     public final void testGetPropertyStringString() {
-        assertEquals("present property", commandLine.getProperty("present", "default property"));
-        assertEquals("default property", commandLine.getProperty("missing", "default property"));
+        assertEquals("present property", commandLine.getProperty(new PropertyOption(), "present",
"default property"));
+        assertEquals("default property", commandLine.getProperty(new PropertyOption(), "missing",
"default property"));
     }
 
     public final void testGetProperties() {
@@ -272,23 +272,23 @@
 
     // OLD TESTS FOLLOW
     public final void testProperties() {
-        final Option option = new PropertyOption();
+        final PropertyOption option = new PropertyOption();
         final List args = CLITestCase.list();
         final WriteableCommandLine writeable = OptionTestCase.commandLine(option, args);
 
-        assertTrue(writeable.getProperties().isEmpty());
+        assertTrue(writeable.getProperties(option).isEmpty());
 
-        writeable.addProperty("myprop", "myval");
-        assertEquals(1, writeable.getProperties().size());
-        assertEquals("myval", writeable.getProperty("myprop"));
-
-        writeable.addProperty("myprop", "myval2");
-        assertEquals(1, writeable.getProperties().size());
-        assertEquals("myval2", writeable.getProperty("myprop"));
-
-        writeable.addProperty("myprop2", "myval3");
-        assertEquals(2, writeable.getProperties().size());
-        assertEquals("myval3", writeable.getProperty("myprop2"));
+        writeable.addProperty(option, "myprop", "myval");
+        assertEquals(1, writeable.getProperties(option).size());
+        assertEquals("myval", writeable.getProperty(option, "myprop"));
+
+        writeable.addProperty(option, "myprop", "myval2");
+        assertEquals(1, writeable.getProperties(option).size());
+        assertEquals("myval2", writeable.getProperty(option, "myprop"));
+
+        writeable.addProperty(option, "myprop2", "myval3");
+        assertEquals(2, writeable.getProperties(option).size());
+        assertEquals("myval3", writeable.getProperty(option, "myprop2"));
     }
 
     public final void testOptions() {

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/WriteableCommandLineTestCase.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/WriteableCommandLineTestCase.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/WriteableCommandLineTestCase.java
(original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/WriteableCommandLineTestCase.java
Tue Jul 22 13:27:09 2008
@@ -17,6 +17,7 @@
 package org.apache.commons.cli2;
 
 import org.apache.commons.cli2.option.ArgumentTest;
+import org.apache.commons.cli2.option.PropertyOption;
 
 /**
  * @author Rob Oxspring
@@ -33,7 +34,7 @@
 	protected final CommandLine createCommandLine() {
 		final WriteableCommandLine cl = createWriteableCommandLine();
 		cl.addOption(present);
-		cl.addProperty("present","present property");
+		cl.addProperty(new PropertyOption(), "present","present property");
 		cl.addSwitch(bool,true);
 		cl.addValue(present,"present value");
 		cl.addOption(multiple);
@@ -82,9 +83,9 @@
 		assertTrue(writeable.hasOption(present));
 	}
 	public final void testAddProperty() {
-		assertNull(writeable.getProperty("present"));
-		writeable.addProperty("present","present value");
-		assertEquals("present value",writeable.getProperty("present"));
+		assertNull(writeable.getProperty(new PropertyOption(), "present"));
+		writeable.addProperty(new PropertyOption(), "present","present value");
+		assertEquals("present value",writeable.getProperty(new PropertyOption(), "present"));
 	}
 	public final void testLooksLikeOption() {
 		//TODO Implement looksLikeOption().

Added: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java?rev=678886&view=auto
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java (added)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java Tue Jul
22 13:27:09 2008
@@ -0,0 +1,32 @@
+package org.apache.commons.cli2.bug;
+
+import junit.framework.TestCase;
+import org.apache.commons.cli2.option.PropertyOption;
+import org.apache.commons.cli2.Group;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.OptionException;
+import org.apache.commons.cli2.commandline.Parser;
+import org.apache.commons.cli2.builder.GroupBuilder;
+
+/**
+ * @author brianegge
+ */
+public class BugCLI126Test extends TestCase {
+    public void testMultiplePropertyArgs() throws OptionException {
+        PropertyOption conf = new PropertyOption("-P", "Properties for this process", 1);
+        PropertyOption env = new PropertyOption("-C", "Properties for child processes", 2);
+        GroupBuilder builder = new GroupBuilder();
+        Group options = builder.withOption(conf).withOption(env).create();
+
+        Parser parser = new Parser();
+        parser.setGroup(options);
+        CommandLine line =
+            parser.parseAndHelp(
+                new String[] {
+                    "-Phome=.",
+                    "-Chome=/"
+                    });
+        assertEquals(".", line.getProperty(conf, "home"));
+        assertEquals("/", line.getProperty(env, "home"));
+    }
+}

Propchange: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI126Test.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI12Test.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI12Test.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI12Test.java (original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugCLI12Test.java Tue Jul
22 13:27:09 2008
@@ -35,7 +35,7 @@
   public void testBug() {
     Argument arg = new ArgumentBuilder().withName("file").create();
 
-    Option option = new PropertyOption();
+    PropertyOption option = new PropertyOption();
 
     Group group = new GroupBuilder().withOption(option).withOption(arg).create();
 
@@ -47,8 +47,8 @@
       assertTrue("Couldn't parse valid commandLine", false);
     }
 
-    assertEquals( "myval1", cl.getProperty("myprop1"));
-    assertEquals( "myval2", cl.getProperty("myprop2"));
+    assertEquals( "myval1", cl.getProperty(option, "myprop1"));
+    assertEquals( "myval2", cl.getProperty(option, "myprop2"));
 
     String extraArgs = (String) cl.getValue(arg);
     assertEquals( "myfile", extraArgs);

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/DefaultingCommandLineTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/DefaultingCommandLineTest.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/DefaultingCommandLineTest.java
(original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/commandline/DefaultingCommandLineTest.java
Tue Jul 22 13:27:09 2008
@@ -25,6 +25,7 @@
 import org.apache.commons.cli2.CommandLineTestCase;
 import org.apache.commons.cli2.Option;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.option.PropertyOption;
 import org.apache.commons.cli2.builder.DefaultOptionBuilder;
 
 /**
@@ -44,7 +45,7 @@
     protected final CommandLine createCommandLine() {
         final WriteableCommandLine writeable = new WriteableCommandLineImpl(root, new ArrayList());
         writeable.addOption(present);
-        writeable.addProperty("present", "present property");
+        writeable.addProperty(new PropertyOption(), "present", "present property");
         writeable.addSwitch(bool, true);
         writeable.addValue(present, "present value");
         writeable.addOption(multiple);

Modified: commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java?rev=678886&r1=678885&r2=678886&view=diff
==============================================================================
--- commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
(original)
+++ commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
Tue Jul 22 13:27:09 2008
@@ -75,15 +75,15 @@
      * @see org.apache.commons.cli2.OptionTestCase#testProcess()
      */
     public void testProcess() throws OptionException {
-        final Option option = new PropertyOption();
+        final PropertyOption option = new PropertyOption();
         final List args = list("-Dmyprop=myvalue");
         final WriteableCommandLine commandLine = commandLine(option, args);
         final ListIterator iterator = args.listIterator();
 
         option.process(commandLine, iterator);
-        assertEquals("myvalue", commandLine.getProperty("myprop"));
+        assertEquals("myvalue", commandLine.getProperty(option, "myprop"));
         assertFalse(iterator.hasNext());
-        assertEquals(1, commandLine.getProperties().size());
+        assertEquals(1, commandLine.getProperties(option).size());
     }
 
     public void testProcess_UnexpectedOptionException() {
@@ -105,26 +105,26 @@
     }
 
     public void testProcess_BadPropertyException() throws OptionException {
-        final Option option = new PropertyOption();
+        final PropertyOption option = new PropertyOption();
         final List args = list("-Dmyprop");
         final WriteableCommandLine commandLine = commandLine(option, args);
         final ListIterator iterator = args.listIterator();
 
         option.process(commandLine, iterator);
 
-        assertEquals("true", commandLine.getProperty("myprop"));
+        assertEquals("true", commandLine.getProperty(option, "myprop"));
     }
 
     public void testProcess_SetToEmpty() throws OptionException {
-        final Option option = new PropertyOption();
+        final PropertyOption option = new PropertyOption();
         final List args = list("-Dmyprop=");
         final WriteableCommandLine commandLine = commandLine(option, args);
         final ListIterator iterator = args.listIterator();
 
         option.process(commandLine, iterator);
-        assertEquals("", commandLine.getProperty("myprop"));
+        assertEquals("", commandLine.getProperty(option, "myprop"));
         assertFalse(iterator.hasNext());
-        assertEquals(1, commandLine.getProperties().size());
+        assertEquals(1, commandLine.getProperties(option).size());
     }
 
     /*



Mime
View raw message