Skip to content

Commit 7054900

Browse files
committed
Adding Andrew's unit tests for CLI-18 - they pass for me too, so marking the issue as Cannot Reproduce
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@412466 13f79535-47bb-0310-9956-ffa450edef68
1 parent 1d040ce commit 7054900

2 files changed

Lines changed: 101 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
* Copyright 2004 The Apache Software Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.commons.cli.bug;
17+
18+
import org.apache.commons.cli.*;
19+
20+
import java.io.PrintWriter;
21+
import java.io.StringWriter;
22+
23+
import junit.framework.TestCase;
24+
25+
/**
26+
* http://issues.apache.org/jira/browse/CLI-18
27+
*/
28+
public class BugCLI18Test extends TestCase {
29+
30+
public void testCLI18() {
31+
Options options = new Options();
32+
options.addOption(new Option("a","aaa",false,"aaaaaaa"));
33+
options.addOption(new Option(null,"bbb",false,"bbbbbbb dksh fkshd fkhs dkfhsdk fhskd hksdks dhfowehfsdhfkjshf skfhkshf sf jkshfk sfh skfh skf f"));
34+
options.addOption(new Option("c",null,false,"ccccccc"));
35+
36+
HelpFormatter formatter = new HelpFormatter();
37+
StringWriter out = new StringWriter();
38+
39+
formatter.printHelp(new PrintWriter(out),80, "foobar", "dsfkfsh kdh hsd hsdh fkshdf ksdh fskdh fsdh fkshfk sfdkjhskjh fkjh fkjsh khsdkj hfskdhf skjdfh ksf khf s", options, 2, 2, "blort j jgj j jg jhghjghjgjhgjhg jgjhgj jhg jhg hjg jgjhghjg jhg hjg jhgjg jgjhghjg jg jgjhgjgjg jhg jhgjh" + '\r' + '\n' + "rarrr", true);
40+
}
41+
}
42+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Copyright 2004 The Apache Software Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.apache.commons.cli2.bug;
17+
18+
import java.io.PrintWriter;
19+
import java.io.StringWriter;
20+
21+
import org.apache.commons.cli2.Group;
22+
import org.apache.commons.cli2.Option;
23+
import org.apache.commons.cli2.builder.DefaultOptionBuilder;
24+
import org.apache.commons.cli2.builder.GroupBuilder;
25+
import org.apache.commons.cli2.util.HelpFormatter;
26+
27+
import junit.framework.TestCase;
28+
29+
/**
30+
* http://issues.apache.org/jira/browse/CLI-18
31+
*/
32+
public class BugCLI18Test extends TestCase {
33+
34+
public BugCLI18Test() {
35+
super();
36+
}
37+
38+
39+
public void testBug() {
40+
Option a = new DefaultOptionBuilder().withLongName("aaa").withShortName("a").withDescription("aaaaaaa").create();
41+
Option b = new DefaultOptionBuilder().withLongName("bbb").withDescription("bbbbbbbb dksh fkshd fkhs dkfhsdk fhskd hksdks dhfowehfsdhfkjshf skfhkshf sf jkshfk sfh skfh skf f").create();
42+
Option c = new DefaultOptionBuilder().withLongName("ccc").withShortName("c").withDescription("ccccccc").create();
43+
44+
Group g = new GroupBuilder().withOption(a).withOption(b).withOption(c).create();
45+
46+
HelpFormatter formatter = new HelpFormatter();
47+
StringWriter out = new StringWriter();
48+
49+
formatter.setPrintWriter(new PrintWriter(out));
50+
formatter.setHeader("dsfkfsh kdh hsd hsdh fkshdf ksdh fskdh fsdh fkshfk sfdkjhskjh fkjh fkjsh khsdkj hfskdhf skjdfh ksf khf s");
51+
formatter.setFooter("blort j jgj j jg jhghjghjgjhgjhg jgjhgj jhg jhg hjg jgjhghjg jhg hjg jhgjg jgjhghjg jg jgjhgjgjg jhg jhgjh" + '\r' + '\n' + "rarrr");
52+
formatter.setGroup(g);
53+
formatter.setShellCommand("foobar");
54+
55+
formatter.print();
56+
57+
}
58+
}
59+

0 commit comments

Comments
 (0)