@@ -48,7 +48,6 @@ public void testClassPattern() throws Exception {
4848 final Options options = PatternOptionBuilder .parsePattern ("c+d+" );
4949 final CommandLineParser parser = new PosixParser ();
5050 final CommandLine line = parser .parse (options , new String [] {"-c" , "java.util.Calendar" , "-d" , "System.DateTime" });
51-
5251 assertEquals (Calendar .class , line .getOptionObject ("c" ), "c value" );
5352 assertNull (line .getOptionObject ("d" ), "d value" );
5453 }
@@ -64,9 +63,7 @@ public void testExistingFilePattern() throws Exception {
6463 final Options options = PatternOptionBuilder .parsePattern ("g<" );
6564 final CommandLineParser parser = new PosixParser ();
6665 final CommandLine line = parser .parse (options , new String [] {"-g" , "src/test/resources/org/apache/commons/cli/existing-readable.file" });
67-
6866 final Object parsedReadableFileStream = line .getOptionObject ("g" );
69-
7067 assertNotNull (parsedReadableFileStream , "option g not parsed" );
7168 assertInstanceOf (FileInputStream .class , parsedReadableFileStream , "option g not FileInputStream" );
7269 }
@@ -76,7 +73,6 @@ public void testExistingFilePatternFileNotExist() throws Exception {
7673 final Options options = PatternOptionBuilder .parsePattern ("f<" );
7774 final CommandLineParser parser = new PosixParser ();
7875 final CommandLine line = parser .parse (options , new String [] {"-f" , "non-existing.file" });
79-
8076 assertNull (line .getOptionObject ("f" ), "option f parsed" );
8177 }
8278
@@ -86,14 +82,11 @@ public void testNumberPattern() throws Exception {
8682 final CommandLineParser parser = new PosixParser ();
8783 // 3,5 fails validation.
8884 //assertThrows(ParseException.class, () -> parser.parse(options, new String[] {"-n", "1", "-d", "2.1", "-x", "3,5"}));
89-
9085 final CommandLine line = parser .parse (options , new String [] {"-n" , "1" , "-d" , "2.1" , "-x" , "3,5" });
9186 assertEquals (Long .class , line .getOptionObject ("n" ).getClass (), "n object class" );
9287 assertEquals (Long .valueOf (1 ), line .getOptionObject ("n" ), "n value" );
93-
9488 assertEquals (Double .class , line .getOptionObject ("d" ).getClass (), "d object class" );
9589 assertEquals (Double .valueOf (2.1 ), line .getOptionObject ("d" ), "d value" );
96-
9790 assertNull (line .getOptionObject ("x" ), "x object" );
9891 }
9992
@@ -102,7 +95,6 @@ public void testObjectPattern() throws Exception {
10295 final Options options = PatternOptionBuilder .parsePattern ("o@i@n@" );
10396 final CommandLineParser parser = new PosixParser ();
10497 final CommandLine line = parser .parse (options , new String [] {"-o" , "java.lang.String" , "-i" , "java.util.Calendar" , "-n" , "System.DateTime" });
105-
10698 assertEquals ("" , line .getOptionObject ("o" ), "o value" );
10799 assertNull (line .getOptionObject ("i" ), "i value" );
108100 assertNull (line .getOptionObject ("n" ), "n value" );
@@ -112,7 +104,6 @@ public void testObjectPattern() throws Exception {
112104 public void testRequiredOption () throws Exception {
113105 final Options options = PatternOptionBuilder .parsePattern ("!n%m%" );
114106 final CommandLineParser parser = new PosixParser ();
115-
116107 try {
117108 parser .parse (options , new String [] {"" });
118109 fail ("MissingOptionException wasn't thrown" );
@@ -135,10 +126,8 @@ public void testSimplePattern() throws Exception {
135126 final DateFormat dateFormat = new SimpleDateFormat ("EEE MMM dd HH:mm:ss zzz yyyy" );
136127 final String [] args = {"-c" , "-a" , "foo" , "-b" , "java.util.Vector" , "-e" , "build.xml" , "-f" , "java.util.Calendar" , "-n" , "4.5" , "-t" ,
137128 "https://commons.apache.org" , "-z" , dateFormat .format (expectedDate ), "-m" , "test*" };
138-
139129 final CommandLineParser parser = new PosixParser ();
140130 final CommandLine line = parser .parse (options , args );
141-
142131 assertEquals ("foo" , line .getOptionValue ("a" ), "flag a" );
143132 assertEquals ("foo" , line .getOptionObject ("a" ), "string flag a" );
144133 assertEquals (new Vector <>(), line .getOptionObject ("b" ), "object flag b" );
@@ -148,7 +137,6 @@ public void testSimplePattern() throws Exception {
148137 assertEquals (Calendar .class , line .getOptionObject ("f" ), "class flag f" );
149138 assertEquals (Double .valueOf (4.5 ), line .getOptionObject ("n" ), "number flag n" );
150139 assertEquals (new URL ("https://commons.apache.org" ), line .getOptionObject ("t" ), "url flag t" );
151-
152140 // tests the char methods of CommandLine that delegate to the String methods
153141 assertEquals ("foo" , line .getOptionValue ('a' ), "flag a" );
154142 assertEquals ("foo" , line .getOptionObject ('a' ), "string flag a" );
@@ -159,10 +147,8 @@ public void testSimplePattern() throws Exception {
159147 assertEquals (Calendar .class , line .getOptionObject ('f' ), "class flag f" );
160148 assertEquals (Double .valueOf (4.5 ), line .getOptionObject ('n' ), "number flag n" );
161149 assertEquals (new URL ("https://commons.apache.org" ), line .getOptionObject ('t' ), "url flag t" );
162-
163150 // FILES NOT SUPPORTED YET
164151 assertThrows (UnsupportedOperationException .class , () -> line .getOptionObject ('m' ));
165-
166152 assertEquals (expectedDate , line .getOptionObject ('z' ), "date flag z" );
167153
168154 }
@@ -172,7 +158,6 @@ public void testUntypedPattern() throws Exception {
172158 final Options options = PatternOptionBuilder .parsePattern ("abc" );
173159 final CommandLineParser parser = new PosixParser ();
174160 final CommandLine line = parser .parse (options , new String [] {"-abc" });
175-
176161 assertTrue (line .hasOption ('a' ));
177162 assertNull (line .getOptionObject ('a' ), "value a" );
178163 assertTrue (line .hasOption ('b' ));
@@ -186,7 +171,6 @@ public void testURLPattern() throws Exception {
186171 final Options options = PatternOptionBuilder .parsePattern ("u/v/" );
187172 final CommandLineParser parser = new PosixParser ();
188173 final CommandLine line = parser .parse (options , new String [] {"-u" , "https://commons.apache.org" , "-v" , "foo://commons.apache.org" });
189-
190174 assertEquals (new URL ("https://commons.apache.org" ), line .getOptionObject ("u" ), "u value" );
191175 assertNull (line .getOptionObject ("v" ), "v value" );
192176 }
0 commit comments