|
24 | 24 | * applications command lines focusing on options with |
25 | 25 | * long and short names. |
26 | 26 | */ |
27 | | -public class LongOptionWithShort extends TestCase { |
| 27 | +public class PosixParserTest extends TestCase { |
28 | 28 |
|
29 | | - public void testLongOptionWithShort() { |
| 29 | + public void testLongOptionWithShort() throws Exception { |
30 | 30 | Option help = new Option("h", "help", false, "print this message"); |
31 | | - Option version = new Option("v", "version", false, |
32 | | - "print version information"); |
33 | | - Option newRun = new Option("n", "new", false, |
34 | | - "Create NLT cache entries only for new items"); |
35 | | - Option trackerRun = new Option("t", "tracker", false, |
36 | | - "Create NLT cache entries only for tracker items"); |
| 31 | + Option version = new Option("v", "version", false, "print version information"); |
| 32 | + Option newRun = new Option("n", "new", false, "Create NLT cache entries only for new items"); |
| 33 | + Option trackerRun = new Option("t", "tracker", false, "Create NLT cache entries only for tracker items"); |
37 | 34 |
|
38 | 35 | Option timeLimit = OptionBuilder.withLongOpt("limit").hasArg() |
39 | 36 | .withValueSeparator() |
@@ -84,17 +81,12 @@ public void testLongOptionWithShort() { |
84 | 81 | "filename" |
85 | 82 | }; |
86 | 83 |
|
87 | | - try { |
88 | | - CommandLine line = parser.parse(options, args); |
89 | | - assertTrue(line.hasOption("v")); |
90 | | - assertEquals(line.getOptionValue("l"), "10"); |
91 | | - assertEquals(line.getOptionValue("limit"), "10"); |
92 | | - assertEquals(line.getOptionValue("a"), "5"); |
93 | | - assertEquals(line.getOptionValue("age"), "5"); |
94 | | - assertEquals(line.getOptionValue("file"), "filename"); |
95 | | - } |
96 | | - catch (ParseException exp) { |
97 | | - fail("Unexpected exception:" + exp.getMessage()); |
98 | | - } |
| 84 | + CommandLine line = parser.parse(options, args); |
| 85 | + assertTrue(line.hasOption("v")); |
| 86 | + assertEquals(line.getOptionValue("l"), "10"); |
| 87 | + assertEquals(line.getOptionValue("limit"), "10"); |
| 88 | + assertEquals(line.getOptionValue("a"), "5"); |
| 89 | + assertEquals(line.getOptionValue("age"), "5"); |
| 90 | + assertEquals(line.getOptionValue("file"), "filename"); |
99 | 91 | } |
100 | 92 | } |
0 commit comments