2222import java .io .PrintWriter ;
2323import java .io .StringWriter ;
2424import java .util .Iterator ;
25+ import java .util .List ;
2526import java .util .Properties ;
2627
2728import junit .framework .TestCase ;
@@ -31,8 +32,7 @@ public class BugsTest extends TestCase
3132 public void test11457 () throws Exception
3233 {
3334 Options options = new Options ();
34- options .addOption (OptionBuilder .withLongOpt ("verbose" )
35- .create ());
35+ options .addOption (OptionBuilder .withLongOpt ("verbose" ).create ());
3636 String [] args = new String []{"--verbose" };
3737
3838 CommandLineParser parser = new PosixParser ();
@@ -44,12 +44,8 @@ public void test11457() throws Exception
4444 public void test11458 () throws Exception
4545 {
4646 Options options = new Options ();
47- options .addOption ( OptionBuilder .withValueSeparator ( '=' )
48- .hasArgs ()
49- .create ( 'D' ) );
50- options .addOption ( OptionBuilder .withValueSeparator ( ':' )
51- .hasArgs ()
52- .create ( 'p' ) );
47+ options .addOption ( OptionBuilder .withValueSeparator ( '=' ).hasArgs ().create ( 'D' ) );
48+ options .addOption ( OptionBuilder .withValueSeparator ( ':' ).hasArgs ().create ( 'p' ) );
5349 String [] args = new String [] { "-DJAVA_HOME=/opt/java" , "-pfile1:file2:file3" };
5450
5551 CommandLineParser parser = new PosixParser ();
@@ -107,10 +103,8 @@ public void test11456() throws Exception
107103 {
108104 // Posix
109105 Options options = new Options ();
110- options .addOption ( OptionBuilder .hasOptionalArg ()
111- .create ( 'a' ) );
112- options .addOption ( OptionBuilder .hasArg ()
113- .create ( 'b' ) );
106+ options .addOption ( OptionBuilder .hasOptionalArg ().create ( 'a' ) );
107+ options .addOption ( OptionBuilder .hasArg ().create ( 'b' ) );
114108 String [] args = new String [] { "-a" , "-bvalue" };
115109
116110 CommandLineParser parser = new PosixParser ();
@@ -120,10 +114,8 @@ public void test11456() throws Exception
120114
121115 // GNU
122116 options = new Options ();
123- options .addOption ( OptionBuilder .hasOptionalArg ()
124- .create ( 'a' ) );
125- options .addOption ( OptionBuilder .hasArg ()
126- .create ( 'b' ) );
117+ options .addOption ( OptionBuilder .hasOptionalArg ().create ( 'a' ) );
118+ options .addOption ( OptionBuilder .hasArg ().create ( 'b' ) );
127119 args = new String [] { "-a" , "-b" , "value" };
128120
129121 parser = new GnuParser ();
@@ -227,12 +219,9 @@ public void test13425() throws Exception
227219 public void test13666 () throws Exception
228220 {
229221 Options options = new Options ();
230- Option dir = OptionBuilder .withDescription ( "dir" )
231- .hasArg ()
232- .create ( 'd' );
222+ Option dir = OptionBuilder .withDescription ( "dir" ).hasArg ().create ( 'd' );
233223 options .addOption ( dir );
234224
235-
236225 final PrintStream oldSystemOut = System .out ;
237226 try
238227 {
@@ -279,29 +268,35 @@ public void test13935() throws Exception
279268 boolean exception = false ;
280269
281270 String [] args = new String [] { };
282- try {
283- CommandLine line = parser .parse ( opts , args );
271+ try
272+ {
273+ CommandLine line = parser .parse (opts , args );
284274 }
285- catch ( ParseException exp ) {
275+ catch (ParseException exp )
276+ {
286277 exception = true ;
287278 }
288279
289- if ( !exception ) {
290- fail ( "Expected exception not caught." );
280+ if (!exception )
281+ {
282+ fail ("Expected exception not caught." );
291283 }
292284
293285 exception = false ;
294286
295287 args = new String [] { "-s" };
296- try {
297- CommandLine line = parser .parse ( opts , args );
288+ try
289+ {
290+ CommandLine line = parser .parse (opts , args );
298291 }
299- catch ( ParseException exp ) {
292+ catch (ParseException exp )
293+ {
300294 exception = true ;
301295 }
302296
303- if ( !exception ) {
304- fail ( "Expected exception not caught." );
297+ if (!exception )
298+ {
299+ fail ("Expected exception not caught." );
305300 }
306301
307302 exception = false ;
@@ -328,7 +323,8 @@ public void test13935() throws Exception
328323 }
329324 }
330325
331- public void test14786 () throws Exception {
326+ public void test14786 () throws Exception
327+ {
332328 Option o = OptionBuilder .isRequired ().withDescription ("test" ).create ("test" );
333329 Options opts = new Options ();
334330 opts .addOption (o );
@@ -342,23 +338,25 @@ public void test14786() throws Exception {
342338 assertTrue ( line .hasOption ( "test" ) );
343339 }
344340
345- public void test15046 () throws Exception {
341+ public void test15046 () throws Exception
342+ {
346343 CommandLineParser parser = new PosixParser ();
347- final String [] CLI_ARGS = new String [] {"-z" , "c" };
348- Option option = new Option ( "z" , "timezone" , true ,
349- "affected option" );
350- Options cliOptions = new Options ( );
351- cliOptions . addOption ( option );
352- parser .parse (cliOptions , CLI_ARGS );
353-
344+ String [] CLI_ARGS = new String [] {"-z" , "c" };
345+
346+ Options options = new Options ( );
347+ options . addOption ( new Option ( "z" , "timezone" , true , "affected option" ) );
348+
349+ parser .parse (options , CLI_ARGS );
350+
354351 //now add conflicting option
355- cliOptions .addOption ("c" , "conflict" , true , "conflict option" );
356- CommandLine line = parser .parse (cliOptions , CLI_ARGS );
357- assertEquals ( option . getValue ( ), "c" );
352+ options .addOption ("c" , "conflict" , true , "conflict option" );
353+ CommandLine line = parser .parse (options , CLI_ARGS );
354+ assertEquals ( line . getOptionValue ( 'z' ), "c" );
358355 assertTrue ( !line .hasOption ("c" ) );
359356 }
360357
361- public void test15648 () throws Exception {
358+ public void test15648 () throws Exception
359+ {
362360 CommandLineParser parser = new PosixParser ();
363361 final String [] args = new String [] { "-m" , "\" Two Words\" " };
364362 Option m = OptionBuilder .hasArgs ().create ("m" );
@@ -368,7 +366,8 @@ public void test15648() throws Exception {
368366 assertEquals ( "Two Words" , line .getOptionValue ( "m" ) );
369367 }
370368
371- public void test27635 () {
369+ public void test27635 ()
370+ {
372371 Option help = new Option ("h" , "help" , false , "print this message" );
373372 Option version = new Option ("v" , "version" , false , "print version information" );
374373 Option newRun = new Option ("n" , "new" , false , "Create NLT cache entries only for new items" );
@@ -436,7 +435,8 @@ public void test27635() {
436435 ,out .toString ());
437436 }
438437
439- public void test31148 () throws ParseException {
438+ public void test31148 () throws ParseException
439+ {
440440 Option multiArgOption = new Option ("o" ,"option with multiple args" );
441441 multiArgOption .setArgs (1 );
442442
@@ -453,7 +453,8 @@ public void test31148() throws ParseException {
453453 assertEquals ("ovalue" ,cl .getOptionValue ('o' ));
454454 }
455455
456- public void test21215 () {
456+ public void test21215 ()
457+ {
457458 Options options = new Options ();
458459 HelpFormatter formatter = new HelpFormatter ();
459460 String SEP = System .getProperty ("line.separator" );
@@ -470,7 +471,8 @@ public void test21215() {
470471 ,out .toString ());
471472 }
472473
473- public void test19383 () {
474+ public void test19383 ()
475+ {
474476 Options options = new Options ();
475477 options .addOption (new Option ("a" ,"aaa" ,false ,"aaaaaaa" ));
476478 options .addOption (new Option (null ,"bbb" ,false ,"bbbbbbb" ));
0 commit comments