You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by eb...@apache.org on 2008/06/13 18:21:59 UTC
svn commit: r667585 -
/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
Author: ebourg
Date: Fri Jun 13 09:21:58 2008
New Revision: 667585
URL: http://svn.apache.org/viewvc?rev=667585&view=rev
Log:
Added a test for parsing properties like options
Modified:
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
Modified: commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java?rev=667585&r1=667584&r2=667585&view=diff
==============================================================================
--- commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java (original)
+++ commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/GnuParserTest.java Fri Jun 13 09:21:58 2008
@@ -17,6 +17,9 @@
package org.apache.commons.cli;
+import java.util.Arrays;
+import java.util.List;
+
import junit.framework.TestCase;
public class GnuParserTest extends TestCase
@@ -247,4 +250,23 @@
assertEquals("bar", cl.getOptionValue("foo"));
}
+
+ public void testPropertiesOption() throws Exception
+ {
+ String[] args = new String[] { "-Jsource=1.5", "-Jtarget=1.5", "foo" };
+
+ Options options = new Options();
+ options.addOption(OptionBuilder.withValueSeparator().hasArgs(2).create('J'));
+
+ Parser parser = new GnuParser();
+ CommandLine cl = parser.parse(options, args);
+
+ List values = Arrays.asList(cl.getOptionValues("J"));
+ assertNotNull("null values", values);
+ assertEquals("number of values", 4, values.size());
+ assertEquals("value 1", "source", values.get(0));
+ assertEquals("value 2", "1.5", values.get(1));
+ assertEquals("value 3", "target", values.get(2));
+ assertEquals("value 4", "1.5", values.get(3));
+ }
}