001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.cli2.bug; 018 019import java.io.PrintWriter; 020import java.io.StringWriter; 021 022import org.apache.commons.cli2.Group; 023import org.apache.commons.cli2.Option; 024import org.apache.commons.cli2.builder.DefaultOptionBuilder; 025import org.apache.commons.cli2.builder.GroupBuilder; 026import org.apache.commons.cli2.util.HelpFormatter; 027 028import junit.framework.TestCase; 029 030/** 031 * http://issues.apache.org/jira/browse/CLI-18 032 */ 033public class BugCLI18Test extends TestCase { 034 035 public BugCLI18Test() { 036 super(); 037 } 038 039 040 public void testBug() { 041 Option a = new DefaultOptionBuilder().withLongName("aaa").withShortName("a").withDescription("aaaaaaa").create(); 042 Option b = new DefaultOptionBuilder().withLongName("bbb").withDescription("bbbbbbbb dksh fkshd fkhs dkfhsdk fhskd hksdks dhfowehfsdhfkjshf skfhkshf sf jkshfk sfh skfh skf f").create(); 043 Option c = new DefaultOptionBuilder().withLongName("ccc").withShortName("c").withDescription("ccccccc").create(); 044 045 Group g = new GroupBuilder().withOption(a).withOption(b).withOption(c).create(); 046 047 HelpFormatter formatter = new HelpFormatter(); 048 StringWriter out = new StringWriter(); 049 050 formatter.setPrintWriter(new PrintWriter(out)); 051 formatter.setHeader("dsfkfsh kdh hsd hsdh fkshdf ksdh fskdh fsdh fkshfk sfdkjhskjh fkjh fkjsh khsdkj hfskdhf skjdfh ksf khf s"); 052 formatter.setFooter("blort j jgj j jg jhghjghjgjhgjhg jgjhgj jhg jhg hjg jgjhghjg jhg hjg jhgjg jgjhghjg jg jgjhgjgjg jhg jhgjh" + '\r' + '\n' + "rarrr"); 053 formatter.setGroup(g); 054 formatter.setShellCommand("foobar"); 055 056 formatter.print(); 057 058 } 059} 060