1 /*
2 Java Regular Expressions Plugin API
3
4 Copyright (C) 2002 Jose San Leandro Armend?riz
5 jsanleandro@yahoo.es
6 chousz@yahoo.com
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Lesser General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22
23 Thanks to ACM S.L. for distributing this library under the LGPL license.
24 Contact info: jsr000@terra.es
25 Postal Address: c/Playa de Lagoa, 1
26 Urb. Valdecaba?as
27 Boadilla del monte
28 28660 Madrid
29 Spain
30
31 This library uses an external API to retrieve version information at
32 runtime.
33 So far I haven't released such API as a project itself, but you should be
34 able to download it from the web page where you got this source code.
35
36 ******************************************************************************
37 *
38 * Filename: $RCSfile: HelperTest.java,v $
39 *
40 * Author: Jose San Leandro Armend?riz
41 *
42 * Description: Performs some unit tests on Helper class.
43 *
44 * Last modified by: $Author: chous $ at $Date: 2003/06/21 21:07:25 $
45 *
46 * File version: $Revision: 1.1 $
47 *
48 * Project version: $Name: $
49 * ("Name" means no concrete version has been checked out)
50 *
51 * $Id: HelperTest.java,v 1.1 2003/06/21 21:07:25 chous Exp $
52 *
53 */
54 package unittests.org.acmsl.regexpplugin;
55
56 /*
57 * Importing project-specific classes.
58 */
59 import org.acmsl.regexpplugin.Helper;
60 import org.acmsl.regexpplugin.gnuregexp.HelperGNUAdapter;
61 import org.acmsl.regexpplugin.jakartaoro.HelperOROAdapter;
62 import org.acmsl.regexpplugin.jakartaregexp.HelperRegexpAdapter;
63 import org.acmsl.regexpplugin.jdk14regexp.HelperJDKAdapter;
64 import org.acmsl.regexpplugin.RegexpEngineNotFoundException;
65 import org.acmsl.regexpplugin.RegexpManager;
66
67 /*
68 * Importing some ACM classes.
69 */
70 import org.acmsl.version.Version;
71 import org.acmsl.version.VersionFactory;
72
73 /***
74 * Importing JUnit classes.
75 */
76 import junit.framework.TestCase;
77
78 /***
79 * Performs some unit tests on Helper class.
80 * @testfamily JUnit
81 * @testkind testcase
82 * @testsetup Default TestCase
83 * @testedclass org.acm.regexpplugin.Compiler
84 * @see org.acmsl.regexpplugin.RegexpManager
85 * @author <a href="mailto:jsanleandro@yahoo.es"
86 >Jose San Leandro Armend?riz</a>
87 * @version $Revision: 1.1 $
88 */
89 public class HelperTest
90 extends TestCase
91 implements org.acmsl.patterns.Test
92 {
93 /***
94 * The input text.
95 */
96 public static final String INPUT = "This is an untested test.";
97
98 /***
99 * The text to replace.
100 */
101 public static final String TEXT_TO_REPLACE = "n untested";
102
103 /***
104 * The replacement text.
105 */
106 public static final String REPLACEMENT_TEXT = " tested";
107
108 /***
109 * The successful replacement result.
110 */
111 public static final String SUCCESS = "This is a tested test.";
112
113 /***
114 * Constructs a test case with the given name.
115 * @param name the test case name.
116 */
117 public HelperTest(String name)
118 {
119 super(name);
120 }
121
122 /***
123 * Tests the helper.replaceAll() method.
124 * @see org.acmsl.regexpplugin.Helper
125 */
126 public void testJakartaOroReplaceAll()
127 {
128 try
129 {
130 RegexpManager.useJakartaOroPerl5();
131
132 Helper t_Helper = RegexpManager.createHelper();
133
134 assertTrue(t_Helper != null);
135
136 assertTrue(t_Helper instanceof HelperOROAdapter);
137
138 String t_strResult =
139 t_Helper.replaceAll(INPUT, TEXT_TO_REPLACE, REPLACEMENT_TEXT);
140
141 assertTrue(t_strResult != null);
142
143 assertTrue(t_strResult.equals(SUCCESS));
144 }
145 catch (Exception exception)
146 {
147 fail("" + exception);
148 }
149 }
150
151 /***
152 * Tests the helper.replaceAll() method.
153 * @see org.acmsl.regexpplugin.Helper
154 */
155 public void testJakartaRegexpReplaceAll()
156 {
157 try
158 {
159 RegexpManager.useJakartaRegexp();
160
161 Helper t_Helper = RegexpManager.createHelper();
162
163 assertTrue(t_Helper != null);
164
165 assertTrue(t_Helper instanceof HelperRegexpAdapter);
166
167 String t_strResult =
168 t_Helper.replaceAll(INPUT, TEXT_TO_REPLACE, REPLACEMENT_TEXT);
169
170 assertTrue(t_strResult != null);
171
172 assertTrue(t_strResult.equals(SUCCESS));
173 }
174 catch (Exception exception)
175 {
176 fail("" + exception);
177 }
178 }
179
180 /***
181 * Tests the helper.replaceAll() method.
182 * @see org.acmsl.regexpplugin.Helper
183 */
184 public void testJDKReplaceAll()
185 {
186 try
187 {
188 RegexpManager.useJDK14Regexp();
189
190 Helper t_Helper = RegexpManager.createHelper();
191
192 assertTrue(t_Helper != null);
193
194 assertTrue(t_Helper instanceof HelperJDKAdapter);
195
196 String t_strResult =
197 t_Helper.replaceAll(INPUT, TEXT_TO_REPLACE, REPLACEMENT_TEXT);
198
199 assertTrue(t_strResult != null);
200
201 assertTrue(t_strResult.equals(SUCCESS));
202 }
203 catch (Exception exception)
204 {
205 fail("" + exception);
206 }
207 }
208
209 /***
210 * Tests the helper.replaceAll() method.
211 * @see org.acmsl.regexpplugin.Helper
212 */
213 public void testGNUReplaceAll()
214 {
215 try
216 {
217 RegexpManager.useGNURegexp();
218
219 Helper t_Helper = RegexpManager.createHelper();
220
221 assertTrue(t_Helper != null);
222
223 assertTrue(t_Helper instanceof HelperGNUAdapter);
224
225 String t_strResult =
226 t_Helper.replaceAll(INPUT, TEXT_TO_REPLACE, REPLACEMENT_TEXT);
227
228 assertTrue(t_strResult != null);
229
230 assertTrue(t_strResult.equals(SUCCESS));
231 }
232 catch (Exception exception)
233 {
234 fail("" + exception);
235 }
236 }
237
238 /***
239 * Concrete version object updated everytime it's checked-in in a CVS
240 * repository.
241 */
242 public static final Version VERSION =
243 VersionFactory.createVersion("$Revision: 1.1 $");
244
245 /***
246 * Retrieves the current version of this object.
247 * @return the version object with such information.
248 */
249 public Version getVersion()
250 {
251 return VERSION;
252 }
253
254 /***
255 * Retrieves the current version of this class. It's defined because
256 * this is a utility class that cannot be instantiated.
257 * @return the object with class version information.
258 */
259 public static Version getClassVersion()
260 {
261 return VERSION;
262 }
263 }
This page was automatically generated by Maven