1   package de.fu_berlin.ties.text;
2   
3   import junit.framework.TestCase;
4   // JUnitDoclet begin import
5   import java.util.Arrays;
6   import java.util.HashMap;
7   import java.util.Map;
8   import java.util.regex.Pattern;
9   // JUnitDoclet end import
10  
11  /***
12  * Generated by JUnitDoclet, a tool provided by
13  * ObjectFab GmbH under LGPL.
14  * Please see www.junitdoclet.org, www.gnu.org
15  * and www.objectfab.de for informations about
16  * the tool, the licence and the authors.
17  */
18  
19  
20  public class TextUtilsTest
21  // JUnitDoclet begin extends_implements
22  extends TestCase
23  // JUnitDoclet end extends_implements
24  {
25    // JUnitDoclet begin class
26    TextUtils textutils = null;
27    // JUnitDoclet end class
28    
29    public TextUtilsTest(String name) {
30      // JUnitDoclet begin method TextUtilsTest
31      super(name);
32      // JUnitDoclet end method TextUtilsTest
33    }
34    
35    public de.fu_berlin.ties.text.TextUtils createInstance() throws Exception {
36      // JUnitDoclet begin method testcase.createInstance
37      return null; // singleton
38      // JUnitDoclet end method testcase.createInstance
39    }
40    
41    protected void setUp() throws Exception {
42      // JUnitDoclet begin method testcase.setUp
43      super.setUp();
44      textutils = createInstance();
45      // JUnitDoclet end method testcase.setUp
46    }
47    
48    protected void tearDown() throws Exception {
49      // JUnitDoclet begin method testcase.tearDown
50      textutils = null;
51      super.tearDown();
52      // JUnitDoclet end method testcase.tearDown
53    }
54    
55    public void testCountFirst() throws Exception {
56      // JUnitDoclet begin method countFirst
57      // JUnitDoclet end method countFirst
58    }
59    
60    public void testCountLast() throws Exception {
61      // JUnitDoclet begin method countLast
62      // JUnitDoclet end method countLast
63    }
64    
65    public void testEnsurePrintableName() throws Exception {
66      // JUnitDoclet begin method ensurePrintableName
67      // JUnitDoclet end method ensurePrintableName
68    }
69    
70    public void testJoinAlternatives() throws Exception {
71      // JUnitDoclet begin method joinAlternatives
72      // JUnitDoclet end method joinAlternatives
73    }
74    
75    public void testMultipleReplaceAll() throws Exception {
76      // JUnitDoclet begin method multipleReplaceAll
77      final String[] inputs = {
78          "          GNU GENERAL PUBLIC LICENSE\n\n",
79          "               Version 2, June 1991\r\n",
80          "\n",
81          " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n",
82          "                       59 Temple Place, Suite 330, Boston, MA  ",
83          "02111-1307  USA\n",
84          " Everyone is permitted to copy and distribute verbatim copies\r\n",
85          " of this license document, but changing it is not allowed.\n",
86          "    \n",
87          "\tPreamble  \n",
88          "\n",
89          "  The licenses for most software are designed to take away your\r",
90          "freedom",
91          " to share and change it. "
92      };
93      
94      final String[] expectedOutputs = {
95          "  GNU  GENERAL  PUBLIC  LICENSE\r\n",
96          "  Version  x,  June  xxxx\r\n",
97          "\r\n",
98          "  Copyright  (C)  xxxx,  xxxx  Free  Software  Foundation,  Inc.\r\n",
99          "  xx  TempLe  PLace,  Suite  xxx,  Boston,  MA  ",
100         "xxxxx-xxxx  USA\r\n",
101         "  Everyone  is  permitted  to  copy  and  distribute  verbatim  copies\r\n",
102         "  of  this  License  document,  but  changing  it  is  not  aLLowed.\r\n",
103         "  \r\n",
104         "  PreambLe  \r\n",
105         "\r\n",
106         "  The  Licenses  for  most  software  are  designed  to  take  away  your\r\n",
107         "freedom",
108         "  to  share  and  change  it.  "
109     };
110     
111     final Map emptyMap = new HashMap();
112     final Map<Pattern, String> replacements = new HashMap<Pattern, String>();
113     replacements.put(Pattern.compile("[//t ]+"), "  ");
114     replacements.put(Pattern.compile("[//r//n]+"), "\r\n");
115     replacements.put(Pattern.compile("//p{Digit}"), "x");
116     replacements.put(Pattern.compile("l"), "L");
117     
118     for (int i = 0; i < inputs.length; i++) {
119         assertEquals(TextUtils.multipleReplaceAll(inputs[i], emptyMap),
120             inputs[i]);
121         assertEquals(TextUtils.multipleReplaceAll(inputs[i], replacements),
122             expectedOutputs[i]);        
123     }
124     // JUnitDoclet end method multipleReplaceAll
125   }
126   
127   public void testNormalize() throws Exception {
128     // JUnitDoclet begin method normalize
129     // JUnitDoclet end method normalize
130   }
131   
132   public void testReplaceAll() throws Exception {
133     // JUnitDoclet begin method replaceAll
134     // JUnitDoclet end method replaceAll
135   }
136   
137   public void testShorten() throws Exception {
138     // JUnitDoclet begin method shorten
139     // JUnitDoclet end method shorten
140   }
141   
142   public void testPunctuation() throws Exception {
143     // JUnitDoclet begin method punctuation
144     // JUnitDoclet end method punctuation
145   }
146   
147   public void testPunctuationOrSymbol() throws Exception {
148     // JUnitDoclet begin method punctuationOrSymbol
149     // JUnitDoclet end method punctuationOrSymbol
150   }
151   
152   public void testSplitLines() throws Exception {
153     // JUnitDoclet begin method splitLines
154     final String input = "          GNU GENERAL PUBLIC LICENSE\n"
155         + "               Version 2, June 1991\r\n"
156         + "\n"
157         + " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n"
158         + "                       59 Temple Place, Suite 330, Boston, MA  "
159         + "02111-1307  USA\n"
160         + " Everyone is permitted to copy and distribute verbatim copies\r\n"
161         + " of this license document, but changing it is not allowed.\n"
162         + "    \n"
163         + "\tPreamble  \n"
164         + "\n"
165         + "  The licenses for most software are designed to take away your\r"
166         + "freedom to share and change it. ";
167 
168     final String[] expectedOutput = new String[] {
169         "GNU GENERAL PUBLIC LICENSE",
170         "Version 2, June 1991",
171         "Copyright (C) 1989, 1991 Free Software Foundation, Inc.",
172         "59 Temple Place, Suite 330, Boston, MA  02111-1307  USA",
173         "Everyone is permitted to copy and distribute verbatim copies",
174         "of this license document, but changing it is not allowed.",
175         "Preamble",
176         "The licenses for most software are designed to take away your",
177         "freedom to share and change it."
178     };
179 
180     final String[] output = TextUtils.splitLines(input);
181     assertTrue(Arrays.equals(output, expectedOutput));
182     // JUnitDoclet end method splitLines
183   }
184   
185   public void testSplitLinesExact() throws Exception {
186     // JUnitDoclet begin method splitLinesExact
187     // JUnitDoclet end method splitLinesExact
188   }
189   
190   public void testSplitString() throws Exception {
191     // JUnitDoclet begin method splitString
192     // JUnitDoclet end method splitString
193   }
194   
195   
196   
197   /***
198   * JUnitDoclet moves marker to this method, if there is not match
199   * for them in the regenerated code and if the marker is not empty.
200   * This way, no test gets lost when regenerating after renaming.
201   * Method testVault is supposed to be empty.
202   */
203   public void testVault() throws Exception {
204     // JUnitDoclet begin method testcase.testVault
205     // JUnitDoclet end method testcase.testVault
206   }
207   
208   public static void main(String[] args) {
209     // JUnitDoclet begin method testcase.main
210     junit.textui.TestRunner.run(TextUtilsTest.class);
211     // JUnitDoclet end method testcase.main
212   }
213 }