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 testCaptureAlternatives() throws Exception {
56      // JUnitDoclet begin method captureAlternatives
57      // JUnitDoclet end method captureAlternatives
58    }
59    
60    public void testCountFirst() throws Exception {
61      // JUnitDoclet begin method countFirst
62      // JUnitDoclet end method countFirst
63    }
64    
65    public void testCountLast() throws Exception {
66      // JUnitDoclet begin method countLast
67      // JUnitDoclet end method countLast
68    }
69    
70    public void testEnsurePrintableName() throws Exception {
71      // JUnitDoclet begin method ensurePrintableName
72      // JUnitDoclet end method ensurePrintableName
73    }
74    
75    public void testJoinAlternatives() throws Exception {
76      // JUnitDoclet begin method joinAlternatives
77      // JUnitDoclet end method joinAlternatives
78    }
79    
80    public void testMultipleReplaceAll() throws Exception {
81      // JUnitDoclet begin method multipleReplaceAll
82      final String[] inputs = {
83          "          GNU GENERAL PUBLIC LICENSE\n\n",
84          "               Version 2, June 1991\r\n",
85          "\n",
86          " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n",
87          "                       59 Temple Place, Suite 330, Boston, MA  ",
88          "02111-1307  USA\n",
89          " Everyone is permitted to copy and distribute verbatim copies\r\n",
90          " of this license document, but changing it is not allowed.\n",
91          "    \n",
92          "\tPreamble  \n",
93          "\n",
94          "  The licenses for most software are designed to take away your\r",
95          "freedom",
96          " to share and change it. "
97      };
98      
99      final String[] expectedOutputs = {
100         "  GNU  GENERAL  PUBLIC  LICENSE\r\n",
101         "  Version  x,  June  xxxx\r\n",
102         "\r\n",
103         "  Copyright  (C)  xxxx,  xxxx  Free  Software  Foundation,  Inc.\r\n",
104         "  xx  TempLe  PLace,  Suite  xxx,  Boston,  MA  ",
105         "xxxxx-xxxx  USA\r\n",
106         "  Everyone  is  permitted  to  copy  and  distribute  verbatim  copies\r\n",
107         "  of  this  License  document,  but  changing  it  is  not  aLLowed.\r\n",
108         "  \r\n",
109         "  PreambLe  \r\n",
110         "\r\n",
111         "  The  Licenses  for  most  software  are  designed  to  take  away  your\r\n",
112         "freedom",
113         "  to  share  and  change  it.  "
114     };
115     
116     final Map emptyMap = new HashMap();
117     final Map<Pattern, String> replacements = new HashMap<Pattern, String>();
118     replacements.put(Pattern.compile("[//t ]+"), "  ");
119     replacements.put(Pattern.compile("[//r//n]+"), "\r\n");
120     replacements.put(Pattern.compile("//p{Digit}"), "x");
121     replacements.put(Pattern.compile("l"), "L");
122     
123     for (int i = 0; i < inputs.length; i++) {
124         assertEquals(TextUtils.multipleReplaceAll(inputs[i], emptyMap),
125             inputs[i]);
126         assertEquals(TextUtils.multipleReplaceAll(inputs[i], replacements),
127             expectedOutputs[i]);        
128     }
129     // JUnitDoclet end method multipleReplaceAll
130   }
131   
132   public void testNormalize() throws Exception {
133     // JUnitDoclet begin method normalize
134     // JUnitDoclet end method normalize
135   }
136   
137   public void testReplaceAll() throws Exception {
138     // JUnitDoclet begin method replaceAll
139     // JUnitDoclet end method replaceAll
140   }
141   
142   public void testShorten() throws Exception {
143     // JUnitDoclet begin method shorten
144     // JUnitDoclet end method shorten
145   }
146   
147   public void testPunctuation() throws Exception {
148     // JUnitDoclet begin method punctuation
149     // JUnitDoclet end method punctuation
150   }
151   
152   public void testPunctuationOrSymbol() throws Exception {
153     // JUnitDoclet begin method punctuationOrSymbol
154     // JUnitDoclet end method punctuationOrSymbol
155   }
156   
157   public void testSplitLines() throws Exception {
158     // JUnitDoclet begin method splitLines
159     final String input = "          GNU GENERAL PUBLIC LICENSE\n"
160         + "               Version 2, June 1991\r\n"
161         + "\n"
162         + " Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n"
163         + "                       59 Temple Place, Suite 330, Boston, MA  "
164         + "02111-1307  USA\n"
165         + " Everyone is permitted to copy and distribute verbatim copies\r\n"
166         + " of this license document, but changing it is not allowed.\n"
167         + "    \n"
168         + "\tPreamble  \n"
169         + "\n"
170         + "  The licenses for most software are designed to take away your\r"
171         + "freedom to share and change it. ";
172 
173     final String[] expectedOutput = new String[] {
174         "GNU GENERAL PUBLIC LICENSE",
175         "Version 2, June 1991",
176         "Copyright (C) 1989, 1991 Free Software Foundation, Inc.",
177         "59 Temple Place, Suite 330, Boston, MA  02111-1307  USA",
178         "Everyone is permitted to copy and distribute verbatim copies",
179         "of this license document, but changing it is not allowed.",
180         "Preamble",
181         "The licenses for most software are designed to take away your",
182         "freedom to share and change it."
183     };
184 
185     final String[] output = TextUtils.splitLines(input);
186     assertTrue(Arrays.equals(output, expectedOutput));
187     // JUnitDoclet end method splitLines
188   }
189   
190   public void testSplitLinesExact() throws Exception {
191     // JUnitDoclet begin method splitLinesExact
192     // JUnitDoclet end method splitLinesExact
193   }
194   
195   public void testSplitString() throws Exception {
196     // JUnitDoclet begin method splitString
197     // JUnitDoclet end method splitString
198   }
199   
200   public void testWeaklyNormalize() throws Exception {
201     // JUnitDoclet begin method weaklyNormalize
202     // JUnitDoclet end method weaklyNormalize
203   }
204   
205   public void testWriteln() throws Exception {
206     // JUnitDoclet begin method writeln
207     // JUnitDoclet end method writeln
208   }
209   
210   
211   
212   /***
213   * JUnitDoclet moves marker to this method, if there is not match
214   * for them in the regenerated code and if the marker is not empty.
215   * This way, no test gets lost when regenerating after renaming.
216   * Method testVault is supposed to be empty.
217   */
218   public void testVault() throws Exception {
219     // JUnitDoclet begin method testcase.testVault
220     // JUnitDoclet end method testcase.testVault
221   }
222   
223   public static void main(String[] args) {
224     // JUnitDoclet begin method testcase.main
225     junit.textui.TestRunner.run(TextUtilsTest.class);
226     // JUnitDoclet end method testcase.main
227   }
228 }