commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Leal (JIRA)" <>
Subject [jira] Commented: (CLI-125) Invokes Date Validator for a Date type (fail on real example)
Date Wed, 20 Sep 2006 21:06:23 GMT
    [ ] 
David Leal commented on CLI-125:

I have found another test case that fails and is related with data input argument type:

public final void testPossibleBug2() throws Exception {
    String[] args = new String[] { "-r", "-t", "templateId", "-gCompId",
        "1", "-f", "csv", "-sDate", "01/01/2006", "-eDate",
         "01/02/2006", "-pNames", "name1", "-pValues", "val1" };

Produce the following error:

org.apache.commons.cli2.OptionException: Unexpected -f while processing -l|-t|-sDate|-eDate|-gCompId|-pNames|-pValues|-f
	at org.apache.commons.cli2.option.GroupImpl.validate(
	at org.apache.commons.cli2.option.ParentImpl.validate(
	at org.apache.commons.cli2.option.DefaultOption.validate(
	at org.apache.commons.cli2.option.GroupImpl.validate(
	at org.apache.commons.cli2.commandline.Parser.parse(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(
	at junit.framework.TestCase.runBare(
	at junit.framework.TestResult$1.protect(
	at junit.framework.TestResult.runProtected(
	at junit.framework.TestSuite.runTest(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

but, if I supress the option -eDate it works.

Now if I eliminate the -pNames, -pValues and mantain -sDate, -eDate it works:

public final void testPossibleBug2() throws Exception {
  String[] args = new String[] { "-r", "-t", "templateId", "-gCompId",
      "1", "-f", "csv", "-sDate", "01/01/2006", "-eDate",
      "01/02/2006" };

It looks like a mistery, isn't it, :-)

> Invokes Date Validator for a Date type (fail on real example)
> -------------------------------------------------------------
>                 Key: CLI-125
>                 URL:
>             Project: Commons CLI
>          Issue Type: Bug
>    Affects Versions: Nightly Builds
>            Reporter: David Leal
>         Attachments: BatchCallerCommandLineParser_help_en.out,,,
> Dear Sr,
> I would like to send a fail I have found when testing my real Command Line Parser example.
I have the command line class definition and also the corresponding testing file. (I will
try to add an atachment file).
> The file occurs because it miss understand probably som option definition and it try
to validate a Date type with a date validator which is wrong. I can't isolate the situation
for the moment, but on the testing class you will see exaclty what happend.
> The file occurs with this situation:
> 		args = new String[]{"-holders-options", "-local", "-f", "",
> 				"-movements-options", "-date", "D-3", "-positions-options",
> 				"-local", "-f", "otroNada.txt", "all"};
> 		parser.parse(args);
> but with this:
> 		args = new String[]{"-holders-options", "-local", "-f", "",
> 				"-movements-options", "-date", "D-3", "holders", "movements"};
> 		parser.parse(args);
> it doesn't happend. The -movements-options, -holders-options, -position-options are group
of options. If you invoke the just the option -help you will see the documentation about the
input argument options, also running the test you will get an output file: 
> TestBatchCallerCommandLineParser.out with this output (englis/spanish, it depends of
your local configuration).
> I have defined a DisplaceDateValidator, that extends DateValidator, it just convert a
displace date operator (D-n) in the corresponding date (current day minus n-days). This validator
works, the problem comes when I want to invoke the parser with more group of options. As you
can see on the source code the algorithm for creating -holders-options, -movements-options,
-positions-options, so having one or two or more group options has to be treated on the same
> Thanks, 
> David

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message