|
17 | 17 |
|
18 | 18 | import java.io.ByteArrayOutputStream; |
19 | 19 | import java.io.PrintStream; |
| 20 | +import java.io.PrintWriter; |
20 | 21 | import java.io.StringWriter; |
21 | 22 |
|
22 | 23 | import junit.framework.Test; |
@@ -411,4 +412,72 @@ public void test15648() throws Exception { |
411 | 412 | assertEquals( "Two Words", line.getOptionValue( "m" ) ); |
412 | 413 | } |
413 | 414 |
|
| 415 | + public void test27635() { |
| 416 | + Option help = new Option("h", "help", false, "print this message"); |
| 417 | + Option version = new Option("v", "version", false, "print version information"); |
| 418 | + Option newRun = new Option("n", "new", false, "Create NLT cache entries only for new items"); |
| 419 | + Option trackerRun = new Option("t", "tracker", false, "Create NLT cache entries only for tracker items"); |
| 420 | + |
| 421 | + Option timeLimit = OptionBuilder.withLongOpt("limit") |
| 422 | + .hasArg() |
| 423 | + .withValueSeparator() |
| 424 | + .withDescription("Set time limit for execution, in mintues") |
| 425 | + .create("l"); |
| 426 | + |
| 427 | + Option age = OptionBuilder.withLongOpt("age") |
| 428 | + .hasArg() |
| 429 | + .withValueSeparator() |
| 430 | + .withDescription("Age (in days) of cache item before being recomputed") |
| 431 | + .create("a"); |
| 432 | + |
| 433 | + Option server = OptionBuilder.withLongOpt("server") |
| 434 | + .hasArg() |
| 435 | + .withValueSeparator() |
| 436 | + .withDescription("The NLT server address") |
| 437 | + .create("s"); |
| 438 | + |
| 439 | + Option numResults = OptionBuilder.withLongOpt("results") |
| 440 | + .hasArg() |
| 441 | + .withValueSeparator() |
| 442 | + .withDescription("Number of results per item") |
| 443 | + .create("r"); |
| 444 | + |
| 445 | + Option configFile = OptionBuilder.withLongOpt("config") |
| 446 | + .hasArg() |
| 447 | + .withValueSeparator() |
| 448 | + .withDescription("Use the specified configuration file") |
| 449 | + .create(); |
| 450 | + |
| 451 | + Options mOptions = new Options(); |
| 452 | + mOptions.addOption(help); |
| 453 | + mOptions.addOption(version); |
| 454 | + mOptions.addOption(newRun); |
| 455 | + mOptions.addOption(trackerRun); |
| 456 | + mOptions.addOption(timeLimit); |
| 457 | + mOptions.addOption(age); |
| 458 | + mOptions.addOption(server); |
| 459 | + mOptions.addOption(numResults); |
| 460 | + mOptions.addOption(configFile); |
| 461 | + |
| 462 | + HelpFormatter formatter = new HelpFormatter(); |
| 463 | + final String EOL = System.getProperty("line.separator"); |
| 464 | + StringWriter out = new StringWriter(); |
| 465 | + formatter.printHelp(new PrintWriter(out),80,"commandline","header",mOptions,2,2,"footer",true); |
| 466 | + assertEquals( |
| 467 | + "usage: commandline [--config <arg>] [-r <arg>] [-a <arg>] [-h] [-t] [-n] [-l"+EOL+ |
| 468 | + " <arg>] [-s <arg>] [-v]"+EOL+ |
| 469 | + "header"+EOL+ |
| 470 | + " -a,--age <arg> Age (in days) of cache item before being recomputed"+EOL+ |
| 471 | + " --config <arg> Use the specified configuration file"+EOL+ |
| 472 | + " -h,--help print this message"+EOL+ |
| 473 | + " -l,--limit <arg> Set time limit for execution, in mintues"+EOL+ |
| 474 | + " -n,--new Create NLT cache entries only for new items"+EOL+ |
| 475 | + " -r,--results <arg> Number of results per item"+EOL+ |
| 476 | + " -s,--server <arg> The NLT server address"+EOL+ |
| 477 | + " -t,--tracker Create NLT cache entries only for tracker items"+EOL+ |
| 478 | + " -v,--version print version information"+EOL+ |
| 479 | + "footer"+EOL |
| 480 | + ,out.toString()); |
| 481 | + } |
| 482 | + |
414 | 483 | } |
0 commit comments