commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roxspr...@apache.org
Subject svn commit: r179892 - in /jakarta/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/bug/ test/org/apache/commons/cli2/option/
Date Fri, 03 Jun 2005 21:15:13 GMT
Author: roxspring
Date: Fri Jun  3 14:15:13 2005
New Revision: 179892

URL: http://svn.apache.org/viewcvs?rev=179892&view=rev
Log:
GroupImpl.canProcess() was returning true when the argument looked like an option but wasn't
accepted by the children.
Option.canProcess() now takes a WriteableCommandLine to provide the looksLikeOption() method.
Bug discovered by Steve Alberty

Added:
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java
Modified:
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java
    jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
    jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java (original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/Option.java Fri Jun
 3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@
      *            The argument to be tested
      * @return true if the argument can be processed by this Option
      */
-    boolean canProcess(final String argument);
+    boolean canProcess(final WriteableCommandLine commandLine, final String argument);
 
     /**
      * Indicates whether this Option will be able to process the particular
@@ -77,7 +77,7 @@
      *            the ListIterator over String arguments
      * @return true if the argument can be processed by this Option
      */
-    boolean canProcess(final ListIterator arguments);
+    boolean canProcess(final WriteableCommandLine commandLine, final ListIterator arguments);
 
     /**
      * Identifies the argument prefixes that should trigger this option. This

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/commandline/Parser.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -63,7 +63,7 @@
         group.defaults(commandLine);
 
         final ListIterator iterator = argumentList.listIterator();
-        while (group.canProcess(iterator)) {
+        while (group.canProcess(commandLine, iterator)) {
             group.process(commandLine, iterator);
         }
 

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ArgumentImpl.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -195,7 +195,7 @@
         }
     }
 
-    public boolean canProcess(String arg) {
+    public boolean canProcess(final WriteableCommandLine commandLine, final String arg) {
         return true;
     }
 

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Command.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -109,7 +109,7 @@
         final String arg = (String)arguments.next();
 
         // if we can process it
-        if (canProcess(arg)) {
+        if (canProcess(commandLine, arg)) {
 
             // then note the option
             commandLine.addOption(this);

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/DefaultOption.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -127,9 +127,9 @@
         checkPrefixes(newPrefixes);
     }
 
-    public boolean canProcess(final String argument) {
+    public boolean canProcess(final WriteableCommandLine commandLine, final String argument)
{
         return argument != null
-            && (super.canProcess(argument)
+            && (super.canProcess(commandLine, argument)
                 || (argument.length() >= burstLength
                     && burstAliases.contains(argument.substring(0, burstLength))));
     }

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/GroupImpl.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -113,7 +113,7 @@
         this.prefixes = Collections.unmodifiableSet(newPrefixes);
     }
 
-    public boolean canProcess(String arg) {
+    public boolean canProcess(final WriteableCommandLine commandLine, String arg) {
         if (arg == null) {
             return false;
         }
@@ -131,11 +131,15 @@
             iter.hasNext();) {
             
             final Option option = (Option) iter.next();
-            if (option.canProcess(arg)) {
+            if (option.canProcess(commandLine, arg)) {
                 return true;
             }
         }
         
+        if(commandLine.looksLikeOption(arg)) {
+            return false;
+        }
+        
         // anonymous argument(s) means we can process it
         if (anonymous.size() > 0) {
             return true;
@@ -182,7 +186,7 @@
                     for (Iterator i = values.iterator(); i.hasNext() && !foundMemberOption;)
{
                         final Option option = (Option) i.next();
                         
-                        if (option.canProcess(arg)) {
+                        if (option.canProcess(commandLine, arg)) {
                         	foundMemberOption = true;
                             arguments.previous();
                             option.process(commandLine, arguments);
@@ -210,7 +214,7 @@
                     // canProcess will always return true?
                     for (final Iterator i = anonymous.iterator(); i.hasNext();) {
                         final Argument argument = (Argument)i.next();
-                        if (argument.canProcess(arguments)) {
+                        if (argument.canProcess(commandLine, arguments)) {
                             argument.process(commandLine, arguments);
                         }
                     }

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/OptionImpl.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,11 +43,11 @@
         this.required = required;
     }
 
-    public boolean canProcess(final ListIterator arguments) {
+    public boolean canProcess(final WriteableCommandLine commandLine, final ListIterator
arguments) {
         if (arguments.hasNext()) {
             final String argument = (String)arguments.next();
             arguments.previous();
-            return canProcess(argument);
+            return canProcess(commandLine, argument);
         }
         else {
             return false;

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/ParentImpl.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@
             argument.processValues(commandLine, arguments, this);
         }
 
-        if (children != null && children.canProcess(arguments)) {
+        if (children != null && children.canProcess(commandLine, arguments)) {
             children.process(commandLine, arguments);
         }
     }
@@ -87,7 +87,7 @@
      * 
      * @see org.apache.commons.cli2.Option#canProcess(java.lang.String)
      */
-    public boolean canProcess(final String arg) {
+    public boolean canProcess(final WriteableCommandLine commandLine, final String arg) {
 
         final Set triggers = getTriggers();
         

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/PropertyOption.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -68,7 +68,7 @@
      */
     public static final PropertyOption INSTANCE = new PropertyOption();
 
-    public boolean canProcess(final String argument) {
+    public boolean canProcess(final WriteableCommandLine commandLine, final String argument)
{
         return argument != null
             && argument.startsWith(optionString)
             && argument.length() > optionString.length();
@@ -85,7 +85,7 @@
 
         final String arg = (String)arguments.next();
 
-        if (!canProcess(arg)) {
+        if (!canProcess(commandLine, arg)) {
             throw new OptionException(this, "cli.error.unexpected", arg);
         }
 

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/SourceDestArgument.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -138,7 +138,7 @@
         dest.validate(commandLine, dest);
     }
 
-    public boolean canProcess(final String arg) {
-        return source.canProcess(arg) || dest.canProcess(arg);
+    public boolean canProcess(final WriteableCommandLine commandLine, final String arg) {
+        return source.canProcess(commandLine, arg) || dest.canProcess(commandLine, arg);
     }
 }

Modified: jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java (original)
+++ jakarta/commons/proper/cli/trunk/src/java/org/apache/commons/cli2/option/Switch.java Fri
Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -139,7 +139,7 @@
 
         final String arg = (String)arguments.next();
 
-        if (canProcess(arg)) {
+        if (canProcess(commandLine, arg)) {
             if (arg.startsWith(enabledPrefix)) {
                 commandLine.addSwitch(this, true);
                 arguments.set(enabledPrefix + preferredName);

Added: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java?rev=179892&view=auto
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java
(added)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/bug/BugLoopingOptionLookAlikeTest.java
Fri Jun  3 14:15:13 2005
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2005 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.cli2.bug;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.cli2.Group;
+import org.apache.commons.cli2.OptionException;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.commandline.Parser;
+
+/**
+ * The first is a loop in Parser.parse() if I set a non-declared option. This 
+ * code goes into a loop in Parser.java method parse this “while” loop runs 
+ * endless
+ * 
+ * @author Steve Alberty
+ */
+public class BugLoopingOptionLookAlikeTest extends TestCase {
+
+    public void testLoopingOptionLookAlike() {
+        final DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
+        final ArgumentBuilder abuilder = new ArgumentBuilder();
+        final GroupBuilder gbuilder = new GroupBuilder();
+        final Group options = gbuilder
+            .withName("ant")
+            .withOption(obuilder.withShortName("help").withDescription("print this message").create())
+            .withOption(obuilder.withShortName("projecthelp").withDescription("print project
help information").create())
+            .withOption(abuilder.withName("target").create())
+            .create();
+        
+        final Parser parser = new Parser();
+        parser.setGroup(options);
+        try {
+            parser.parse(new String[] { "-abcdef",
+                    "testfile.txt ", });
+            fail("OptionException");
+        } catch (OptionException e) {
+            assertEquals("Unexpected -abcdef while processing ant",e.getMessage());
+        }
+    }
+}

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ArgumentTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
 import org.apache.commons.cli2.Option;
 import org.apache.commons.cli2.OptionException;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 import org.apache.commons.cli2.resource.ResourceHelper;
 import org.apache.commons.cli2.validation.DateValidator;
 import org.apache.commons.cli2.validation.DateValidatorTest;
@@ -334,7 +335,7 @@
      */
     public void testCanProcess() {
         final Argument option = buildTargetsArgument();
-        assertTrue(option.canProcess("any value"));
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "any value"));
     }
 
     /*
@@ -524,7 +525,7 @@
     public void testCanProcess_ConsumeRemaining() {
         final Option option = buildUsernameArgument();
 
-        assertTrue(option.canProcess("--"));
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "--"));
     }
 
     public void testProcess_ConsumeRemaining() throws OptionException {

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/CommandTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 import org.apache.commons.cli2.OptionException;
 import org.apache.commons.cli2.Parent;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 
 /**
  * @author Rob Oxspring
@@ -107,15 +108,18 @@
      * @see org.apache.commons.cli2.OptionTestCase#testCanProcess()
      */
     public void testCanProcess() {
-        assertTrue(buildStartCommand().canProcess("start"));
+        final Command option = buildStartCommand();
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "start"));
     }
 
     public void testCanProcess_BadMatch() {
-        assertFalse(buildStartCommand().canProcess("stop"));
+        final Command option = buildStartCommand();
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null), "stop"));
     }
 
     public void testCanProcess_Alias() {
-        assertTrue(buildStartCommand().canProcess("go"));
+        final Command option = buildStartCommand();
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "go"));
     }
 
     /*

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/DefaultOptionTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 import org.apache.commons.cli2.OptionException;
 import org.apache.commons.cli2.Parent;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 
 /**
  * @author roberto
@@ -106,12 +107,12 @@
      */
     public void testCanProcess() {
         final DefaultOption option = buildHelpOption();
-        assertTrue(option.canProcess("-?"));
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "-?"));
     }
 
     public void testCanProcess_BadMatch() {
         final DefaultOption option = buildHelpOption();
-        assertFalse(option.canProcess("-H"));
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null), "-H"));
     }
 
     /*

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/GroupTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
 import org.apache.commons.cli2.WriteableCommandLine;
 import org.apache.commons.cli2.builder.DefaultOptionBuilder;
 import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 
 /**
  * @author Rob Oxspring
@@ -141,12 +142,12 @@
      */
     public void testCanProcess() {
         final Group option = buildApacheCommandGroup();
-        assertTrue(option.canProcess("start"));
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "start"));
     }
 
     public void testCanProcess_BadMatch() {
         final Group option = buildApacheCommandGroup();
-        assertFalse(option.canProcess("begin"));
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null), "begin"));
     }
 
     /*

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/ParentTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
 import org.apache.commons.cli2.builder.CommandBuilder;
 import org.apache.commons.cli2.builder.DefaultOptionBuilder;
 import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 
 /**
  * @author Rob Oxspring
@@ -135,17 +136,17 @@
 	 */
 	public void testCanProcess() {
 		final Parent option = buildKParent();
-		assertTrue(option.canProcess("-k"));
+		assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "-k"));
 	}
 
 	public void testCanProcess_BadMatch() {
 		final Parent option = buildKParent();
-		assertFalse(option.canProcess("-K"));
+		assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null), "-K"));
 	}
 
 	public void testCanProcess_ContractedArgument() {
 		final Parent option = buildLibParent();
-		assertTrue(option.canProcess("--lib=/usr/lib"));
+		assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "--lib=/usr/lib"));
 	}
 
 	/* (non-Javadoc)

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/PropertyOptionTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
 import org.apache.commons.cli2.Option;
 import org.apache.commons.cli2.OptionException;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 
 /**
  * @author Rob Oxspring
@@ -39,22 +40,22 @@
      */
     public void testCanProcess() {
         final Option option = new PropertyOption();
-        assertTrue(option.canProcess("-Dmyprop=myval"));
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null), "-Dmyprop=myval"));
     }
 
     public void testCanProcess_Null() {
         final Option option = new PropertyOption();
-        assertFalse(option.canProcess((String) null));
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null), (String)
null));
     }
 
     public void testCanProcess_TooShort() {
         final Option option = new PropertyOption();
-        assertFalse(option.canProcess("-D"));
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null), "-D"));
     }
 
     public void testCanProcess_BadMatch() {
         final Option option = new PropertyOption();
-        assertFalse(option.canProcess("-dump"));
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null),"-dump"));
     }
 
     /*

Modified: jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java?rev=179892&r1=179891&r2=179892&view=diff
==============================================================================
--- jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java
(original)
+++ jakarta/commons/proper/cli/trunk/src/test/org/apache/commons/cli2/option/SwitchTest.java
Fri Jun  3 14:15:13 2005
@@ -1,5 +1,5 @@
 /**
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
 import org.apache.commons.cli2.OptionException;
 import org.apache.commons.cli2.Parent;
 import org.apache.commons.cli2.WriteableCommandLine;
+import org.apache.commons.cli2.commandline.WriteableCommandLineImpl;
 
 /**
  * @author Rob Oxspring
@@ -93,12 +94,12 @@
      */
     public void testCanProcess() {
         final Switch option = buildDisplaySwitch();
-        assertTrue(option.canProcess("+d"));
+        assertTrue(option.canProcess(new WriteableCommandLineImpl(option,null),"+d"));
     }
 
     public void testCanProcess_BadMatch() {
         final Switch option = buildDisplaySwitch();
-        assertFalse(option.canProcess("-dont"));
+        assertFalse(option.canProcess(new WriteableCommandLineImpl(option,null),"-dont"));
     }
 
     /*



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