@@ -18,6 +18,7 @@ Licensed to the Apache Software Foundation (ASF) under one or more
1818package org .apache .commons .cli ;
1919
2020import static org .junit .Assert .assertEquals ;
21+ import static org .junit .Assert .assertFalse ;
2122import static org .junit .Assert .assertNotNull ;
2223import static org .junit .Assert .assertTrue ;
2324import static org .junit .Assert .fail ;
@@ -77,12 +78,12 @@ public void testNoOptionsExtraArgs() throws Exception {
7778
7879 final CommandLine cl = parser .parse (options , args );
7980
80- assertTrue ("Confirm -r is NOT set" , ! cl .hasOption ("r" ));
81- assertTrue ("Confirm -f is NOT set" , ! cl .hasOption ("f" ));
82- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
83- assertTrue ("Confirm -s is NOT set" , ! cl .hasOption ("s" ));
84- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
85- assertTrue ("Confirm TWO extra args" , cl .getArgList ().size () == 2 );
81+ assertFalse ("Confirm -r is NOT set" , cl .hasOption ("r" ));
82+ assertFalse ("Confirm -f is NOT set" , cl .hasOption ("f" ));
83+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
84+ assertFalse ("Confirm -s is NOT set" , cl .hasOption ("s" ));
85+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
86+ assertEquals ("Confirm TWO extra args" , 2 , cl .getArgList ().size ());
8687 }
8788
8889 @ Test
@@ -91,11 +92,11 @@ public void testSingleLongOption() throws Exception {
9192
9293 final CommandLine cl = parser .parse (options , args );
9394
94- assertTrue ("Confirm -r is NOT set" , ! cl .hasOption ("r" ));
95+ assertFalse ("Confirm -r is NOT set" , cl .hasOption ("r" ));
9596 assertTrue ("Confirm -f is set" , cl .hasOption ("f" ));
96- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
97- assertTrue ("Confirm -s is NOT set" , ! cl .hasOption ("s" ));
98- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
97+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
98+ assertFalse ("Confirm -s is NOT set" , cl .hasOption ("s" ));
99+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
99100 assertTrue ("Confirm no extra args" , cl .getArgList ().isEmpty ());
100101 }
101102
@@ -106,10 +107,10 @@ public void testSingleOption() throws Exception {
106107 final CommandLine cl = parser .parse (options , args );
107108
108109 assertTrue ("Confirm -r is set" , cl .hasOption ("r" ));
109- assertTrue ("Confirm -f is NOT set" , ! cl .hasOption ("f" ));
110- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
111- assertTrue ("Confirm -s is NOT set" , ! cl .hasOption ("s" ));
112- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
110+ assertFalse ("Confirm -f is NOT set" , cl .hasOption ("f" ));
111+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
112+ assertFalse ("Confirm -s is NOT set" , cl .hasOption ("s" ));
113+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
113114 assertTrue ("Confirm no extra args" , cl .getArgList ().isEmpty ());
114115 }
115116
@@ -119,11 +120,11 @@ public void testSingleOptionFromGroup() throws Exception {
119120
120121 final CommandLine cl = parser .parse (options , args );
121122
122- assertTrue ("Confirm -r is NOT set" , ! cl .hasOption ("r" ));
123+ assertFalse ("Confirm -r is NOT set" , cl .hasOption ("r" ));
123124 assertTrue ("Confirm -f is set" , cl .hasOption ("f" ));
124- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
125- assertTrue ("Confirm -s is NOT set" , ! cl .hasOption ("s" ));
126- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
125+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
126+ assertFalse ("Confirm -s is NOT set" , cl .hasOption ("s" ));
127+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
127128 assertTrue ("Confirm no extra args" , cl .getArgList ().isEmpty ());
128129 }
129130
@@ -165,11 +166,11 @@ public void testTwoOptionsFromDifferentGroup() throws Exception {
165166 final String [] args = {"-f" , "-s" };
166167
167168 final CommandLine cl = parser .parse (options , args );
168- assertTrue ("Confirm -r is NOT set" , ! cl .hasOption ("r" ));
169+ assertFalse ("Confirm -r is NOT set" , cl .hasOption ("r" ));
169170 assertTrue ("Confirm -f is set" , cl .hasOption ("f" ));
170- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
171+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
171172 assertTrue ("Confirm -s is set" , cl .hasOption ("s" ));
172- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
173+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
173174 assertTrue ("Confirm NO extra args" , cl .getArgList ().isEmpty ());
174175 }
175176
@@ -196,7 +197,7 @@ public void testTwoOptionsFromGroupWithProperties() throws Exception {
196197
197198 final CommandLine cl = parser .parse (options , args , properties );
198199 assertTrue (cl .hasOption ("f" ));
199- assertTrue (! cl .hasOption ("d" ));
200+ assertFalse ( cl .hasOption ("d" ));
200201 }
201202
202203 @ Test
@@ -207,9 +208,9 @@ public void testTwoValidLongOptions() throws Exception {
207208
208209 assertTrue ("Confirm -r is set" , cl .hasOption ("r" ));
209210 assertTrue ("Confirm -f is set" , cl .hasOption ("f" ));
210- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
211- assertTrue ("Confirm -s is NOT set" , ! cl .hasOption ("s" ));
212- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
211+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
212+ assertFalse ("Confirm -s is NOT set" , cl .hasOption ("s" ));
213+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
213214 assertTrue ("Confirm no extra args" , cl .getArgList ().isEmpty ());
214215 }
215216
@@ -221,9 +222,9 @@ public void testTwoValidOptions() throws Exception {
221222
222223 assertTrue ("Confirm -r is set" , cl .hasOption ("r" ));
223224 assertTrue ("Confirm -f is set" , cl .hasOption ("f" ));
224- assertTrue ("Confirm -d is NOT set" , ! cl .hasOption ("d" ));
225- assertTrue ("Confirm -s is NOT set" , ! cl .hasOption ("s" ));
226- assertTrue ("Confirm -c is NOT set" , ! cl .hasOption ("c" ));
225+ assertFalse ("Confirm -d is NOT set" , cl .hasOption ("d" ));
226+ assertFalse ("Confirm -s is NOT set" , cl .hasOption ("s" ));
227+ assertFalse ("Confirm -c is NOT set" , cl .hasOption ("c" ));
227228 assertTrue ("Confirm no extra args" , cl .getArgList ().isEmpty ());
228229 }
229230
0 commit comments