1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.cli.bug;
18
19 import junit.framework.TestCase;
20 import org.apache.commons.cli.CommandLine;
21 import org.apache.commons.cli.CommandLineParser;
22 import org.apache.commons.cli.Options;
23 import org.apache.commons.cli.ParseException;
24 import org.apache.commons.cli.PosixParser;
25 import org.apache.commons.cli.OptionBuilder;
26 import org.apache.commons.cli.Option;
27
28 /***
29 * @author brianegge
30 */
31 public class BugCLI51Test
32 extends TestCase
33 {
34 public void test() throws Exception
35 {
36 Options options = buildCommandLineOptions();
37 CommandLineParser parser = new PosixParser();
38 String[] args = new String[] {"-t", "-something" };
39 CommandLine commandLine;
40 commandLine = parser.parse( options, args );
41 assertEquals("-something", commandLine.getOptionValue( 't'));
42 }
43
44 private Options buildCommandLineOptions()
45 {
46 Option opt = OptionBuilder.withArgName( "t").hasArg().create('t');
47 Options options = new Options();
48 options.addOption( opt);
49 return options;
50 }
51 }