jkeyes 2003/10/30 16:20:08
Modified: cli/src/test/org/apache/commons/cli2 ApplicationTest.java
Added: cli/src/test/org/apache/commons/cli2/bugs Bug15046.java
Log:
- added bugs test package
- added test
Revision Changes Path
1.1
jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/bugs/Bug15046.java
Index: Bug15046.java
===================================================================
package org.apache.commons.cli2.bugs;
import junit.framework.TestCase;
import org.apache.commons.cli2.ArgumentBuilder;
import org.apache.commons.cli2.CommandLine;
import org.apache.commons.cli2.CommandLineParser;
import org.apache.commons.cli2.DefaultOptionBuilder;
import org.apache.commons.cli2.Group;
import org.apache.commons.cli2.GroupBuilder;
import org.apache.commons.cli2.Option;
public class Bug15046 extends TestCase {
public Bug15046(String name) {
super(name);
}
public void testParamNamedAsOption() throws Exception {
final String[] CLI_ARGS = new String[] { "-z", "c" };
DefaultOptionBuilder obuilder = new DefaultOptionBuilder();
ArgumentBuilder abuilder = new ArgumentBuilder();
Option option =
obuilder
.withShortName("z")
.withLongName("timezone")
.withDescription("affected option")
.withArgument(abuilder.withName("timezone").create())
.create();
GroupBuilder gbuilder = new GroupBuilder();
Group options =
gbuilder.withName("bug15046").withOption(option).create();
CommandLineParser parser = new CommandLineParser();
parser.setGroup(options);
CommandLine line = parser.parse(CLI_ARGS);
assertEquals("c", line.getValue("-z"));
Option c =
obuilder
.withShortName("c")
.withLongName("conflict")
.withDescription("conflicting option")
.withArgument(abuilder.withName("conflict").create())
.create();
options =
gbuilder
.withName("bug15046")
.withOption(option)
.withOption(c)
.create();
parser.setGroup(options);
line = parser.parse(CLI_ARGS);
assertEquals("c", line.getValue("-z"));
}
}
1.5 +12 -3
jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/ApplicationTest.java
Index: ApplicationTest.java
===================================================================
RCS file:
/home/cvs/jakarta-commons-sandbox/cli/src/test/org/apache/commons/cli2/ApplicationTest.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ApplicationTest.java 28 Oct 2003 22:53:59 -0000 1.4
+++ ApplicationTest.java 31 Oct 2003 00:20:08 -0000 1.5
@@ -60,6 +60,9 @@
*/
package org.apache.commons.cli2;
+import java.util.ArrayList;
+import java.util.List;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
@@ -249,6 +252,12 @@
assertEquals("mybuild.xml", line.getValue("-buildfile"));
assertTrue(line.hasOption("-projecthelp"));
assertFalse(line.hasOption("-help"));
+
+ assertTrue(line.hasOption("target"));
+ final List targets = new ArrayList();
+ targets.add("compile");
+ targets.add("docs");
+ assertEquals(targets, line.getValues("target"));
}
public void testCVS() throws OptionException {
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]