Skip to content

Commit 798f9e5

Browse files
author
Robert James Oxspring
committed
Added test to demonstrate the 27635 has been fixed
PR: 27635 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@130111 13f79535-47bb-0310-9956-ffa450edef68
1 parent cb8c457 commit 798f9e5

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

src/test/org/apache/commons/cli/BugsTest.java

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.ByteArrayOutputStream;
1919
import java.io.PrintStream;
20+
import java.io.PrintWriter;
2021
import java.io.StringWriter;
2122

2223
import junit.framework.Test;
@@ -411,4 +412,72 @@ public void test15648() throws Exception {
411412
assertEquals( "Two Words", line.getOptionValue( "m" ) );
412413
}
413414

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+
414483
}

0 commit comments

Comments
 (0)