Skip to content

Commit 22576c1

Browse files
committed
Unit tests should not write to std out
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/cli/trunk@1677409 13f79535-47bb-0310-9956-ffa450edef68
1 parent 378ba8d commit 22576c1

1 file changed

Lines changed: 47 additions & 2 deletions

File tree

src/test/java/org/apache/commons/cli/ApplicationTest.java

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
import static org.junit.Assert.assertEquals;
2121
import static org.junit.Assert.assertTrue;
2222

23+
import java.io.PrintWriter;
24+
import java.io.StringWriter;
25+
2326
import org.junit.Test;
2427

2528
/**
@@ -220,8 +223,50 @@ public void testMan()
220223
addOption("h", "help", false, "show this usage message.");
221224

222225
HelpFormatter hf = new HelpFormatter();
223-
//hf.printHelp(cmdLine, opts);
224-
hf.printHelp(60, cmdLine, null, options, null);
226+
final String EOL = System.getProperty("line.separator");
227+
StringWriter out = new StringWriter();
228+
hf.printHelp(new PrintWriter(out), 60, cmdLine, null, options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, null, false);
229+
assertEquals("usage: man [-c|-f|-k|-w|-tZT device] [-adlhu7V] [-Mpath]" + EOL +
230+
" [-Ppager] [-Slist] [-msystem] [-pstring]" + EOL +
231+
" [-Llocale] [-eextension] [section] page ..." + EOL +
232+
" -7,--ascii display ASCII translation or" + EOL +
233+
" certain latin1 chars." + EOL +
234+
" -a,--all find all matching manual pages." + EOL +
235+
" -c,--catman used by catman to reformat out of" + EOL +
236+
" date cat pages." + EOL +
237+
" -d,--debug emit debugging messages." + EOL +
238+
" -D,--default reset all options to their" + EOL +
239+
" default values." + EOL +
240+
" -e,--extension limit search to extension type" + EOL +
241+
" 'extension'." + EOL +
242+
" -f,--whatis equivalent to whatis." + EOL +
243+
" -h,--help show this usage message." + EOL +
244+
" -k,--apropos equivalent to apropos." + EOL +
245+
" -l,--local-file interpret 'page' argument(s) as" + EOL +
246+
" local filename(s)" + EOL +
247+
" -L,--locale <arg> define the locale for this" + EOL +
248+
" particular man search." + EOL +
249+
" -M,--manpath <arg> set search path for manual pages" + EOL +
250+
" to 'path'." + EOL +
251+
" -m,--systems <arg> search for man pages from other" + EOL +
252+
" unix system(s)." + EOL +
253+
" -P,--pager <arg> use program 'pager' to display" + EOL +
254+
" output." + EOL +
255+
" -p,--preprocessor <arg> string indicates which" + EOL +
256+
" preprocessor to run." + EOL +
257+
" e - [n]eqn p - pic t - tbl" + EOL +
258+
" g - grap r - refer v -" + EOL +
259+
" vgrind" + EOL +
260+
" -r,--prompt <arg> provide 'less' pager with prompt." + EOL +
261+
" -S,--sections <arg> use colon separated section list." + EOL +
262+
" -t,--troff use troff format pages." + EOL +
263+
" -T,--troff-device <arg> use groff with selected device." + EOL +
264+
" -u,--update force a cache consistency check." + EOL +
265+
" -V,--version show version." + EOL +
266+
" -w,--location print physical location of man" + EOL +
267+
" page(s)." + EOL +
268+
" -Z,--ditroff use groff with selected device." + EOL,
269+
out.toString());
225270
}
226271

227272

0 commit comments

Comments
 (0)