svn-gvsig-desktop / trunk / libraries / libIverUtiles / src-test / com / iver / utiles / vectorUtilities / TestVectorUtilities.java @ 11746
History | View | Annotate | Download (7.91 KB)
1 |
package com.iver.utiles.vectorUtilities; |
---|---|
2 |
|
3 |
import java.text.Collator; |
4 |
import java.util.Locale; |
5 |
import java.util.Vector; |
6 |
|
7 |
import com.iver.utiles.StringComparator; |
8 |
|
9 |
import junit.framework.TestCase; |
10 |
|
11 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
12 |
*
|
13 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
14 |
*
|
15 |
* This program is free software; you can redistribute it and/or
|
16 |
* modify it under the terms of the GNU General Public License
|
17 |
* as published by the Free Software Foundation; either version 2
|
18 |
* of the License, or (at your option) any later version.
|
19 |
*
|
20 |
* This program is distributed in the hope that it will be useful,
|
21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 |
* GNU General Public License for more details.
|
24 |
*
|
25 |
* You should have received a copy of the GNU General Public License
|
26 |
* along with this program; if not, write to the Free Software
|
27 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
28 |
*
|
29 |
* For more information, contact:
|
30 |
*
|
31 |
* Generalitat Valenciana
|
32 |
* Conselleria d'Infraestructures i Transport
|
33 |
* Av. Blasco Ib??ez, 50
|
34 |
* 46010 VALENCIA
|
35 |
* SPAIN
|
36 |
*
|
37 |
* +34 963862235
|
38 |
* gvsig@gva.es
|
39 |
* www.gvsig.gva.es
|
40 |
*
|
41 |
* or
|
42 |
*
|
43 |
* IVER T.I. S.A
|
44 |
* Salamanca 50
|
45 |
* 46005 Valencia
|
46 |
* Spain
|
47 |
*
|
48 |
* +34 963163400
|
49 |
* dac@iver.es
|
50 |
*/
|
51 |
|
52 |
/**
|
53 |
* Tests the methods of {@link VectorUtilities}
|
54 |
*
|
55 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
|
56 |
*/
|
57 |
public class TestVectorUtilities extends TestCase { |
58 |
private static String obj; |
59 |
private static Vector v1 = new Vector(); |
60 |
private static Vector v2 = new Vector(); |
61 |
private static StringComparator stringComparator; |
62 |
|
63 |
/*
|
64 |
* (non-Javadoc)
|
65 |
* @see junit.framework.TestCase#setUp()
|
66 |
*/
|
67 |
protected void setUp() throws Exception { |
68 |
super.setUp();
|
69 |
|
70 |
// Initialize the StringComparator
|
71 |
stringComparator = new StringComparator();
|
72 |
|
73 |
// Sort items of the two vectors
|
74 |
Collator collator = Collator.getInstance(new Locale("es_ES")); |
75 |
|
76 |
stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
|
77 |
} |
78 |
|
79 |
/*
|
80 |
* (non-Javadoc)
|
81 |
* @see junit.framework.TestCase#tearDown()
|
82 |
*/
|
83 |
protected void tearDown() throws Exception { |
84 |
super.tearDown();
|
85 |
} |
86 |
|
87 |
///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) /////
|
88 |
|
89 |
/**
|
90 |
* A test
|
91 |
*/
|
92 |
public void test1() { |
93 |
try {
|
94 |
// Insert at the beginning
|
95 |
obj = new String("First"); |
96 |
|
97 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
98 |
|
99 |
System.out.println("Test 1:\nObj: " + obj + "\nResults: " + v1); |
100 |
} catch (Exception e) { |
101 |
e.printStackTrace(); |
102 |
} |
103 |
} |
104 |
|
105 |
/**
|
106 |
* A test
|
107 |
*/
|
108 |
public void test2() { |
109 |
try {
|
110 |
// Insert at the end
|
111 |
obj = new String("ZZ????"); |
112 |
|
113 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
114 |
|
115 |
System.out.println("Test 2:\nObj: " + obj + "\nResults: " + v1); |
116 |
} catch (Exception e) { |
117 |
e.printStackTrace(); |
118 |
} |
119 |
} |
120 |
|
121 |
/**
|
122 |
* A test
|
123 |
*/
|
124 |
public void test3() { |
125 |
try {
|
126 |
// An insertion
|
127 |
obj = new String("?and?"); |
128 |
|
129 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
130 |
|
131 |
System.out.println("Test 3:\nObj: " + obj + "\nResults: " + v1); |
132 |
} catch (Exception e) { |
133 |
e.printStackTrace(); |
134 |
} |
135 |
} |
136 |
|
137 |
/**
|
138 |
* A test
|
139 |
*/
|
140 |
public void test4() { |
141 |
try {
|
142 |
// An insertion
|
143 |
obj = new String("?AND?"); |
144 |
|
145 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
146 |
|
147 |
System.out.println("Test 4:\nObj: " + obj + "\nResults: " + v1); |
148 |
} catch (Exception e) { |
149 |
e.printStackTrace(); |
150 |
} |
151 |
} |
152 |
|
153 |
/**
|
154 |
* A test
|
155 |
*/
|
156 |
public void test5() { |
157 |
try {
|
158 |
// An insertion
|
159 |
obj = new String("appgvSIG"); |
160 |
|
161 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
162 |
|
163 |
System.out.println("Test 5:\nObj: " + obj + "\nResults: " + v1); |
164 |
} catch (Exception e) { |
165 |
e.printStackTrace(); |
166 |
} |
167 |
} |
168 |
|
169 |
/**
|
170 |
* A test
|
171 |
*/
|
172 |
public void test6() { |
173 |
try {
|
174 |
// An insertion
|
175 |
obj = new String("libIverUtiles"); |
176 |
|
177 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
178 |
|
179 |
System.out.println("Test 6:\nObj: " + obj + "\nResults: " + v1); |
180 |
} catch (Exception e) { |
181 |
e.printStackTrace(); |
182 |
} |
183 |
} |
184 |
|
185 |
/**
|
186 |
* A test
|
187 |
*/
|
188 |
public void test7() { |
189 |
try {
|
190 |
// An insertion
|
191 |
obj = new String("libUI"); |
192 |
|
193 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
194 |
|
195 |
System.out.println("Test 7:\nObj: " + obj + "\nResults: " + v1); |
196 |
} catch (Exception e) { |
197 |
e.printStackTrace(); |
198 |
} |
199 |
} |
200 |
|
201 |
/**
|
202 |
* A test
|
203 |
*/
|
204 |
public void test8() { |
205 |
try {
|
206 |
// An insertion
|
207 |
obj = new String("libIverUtiles"); |
208 |
|
209 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
210 |
|
211 |
System.out.println("Test 8:\nObj: " + obj + "\nResults: " + v1); |
212 |
} catch (Exception e) { |
213 |
e.printStackTrace(); |
214 |
} |
215 |
} |
216 |
|
217 |
/**
|
218 |
* A test
|
219 |
*/
|
220 |
public void test9() { |
221 |
try {
|
222 |
// An insertion
|
223 |
obj = new String("extWFS"); |
224 |
|
225 |
VectorUtilities.addAlphabeticallyOrdered(v1, obj); |
226 |
|
227 |
System.out.println("Test 9:\nObj: " + obj + "\nResults: " + v1); |
228 |
} catch (Exception e) { |
229 |
e.printStackTrace(); |
230 |
} |
231 |
} |
232 |
///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) /////
|
233 |
|
234 |
///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) /////
|
235 |
|
236 |
/**
|
237 |
* A test
|
238 |
*/
|
239 |
public void test11() { |
240 |
try {
|
241 |
// Insert at the beginning
|
242 |
obj = new String("First"); |
243 |
|
244 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
245 |
|
246 |
System.out.println("Test 11:\nObj: " + obj + "\nResults: " + v2); |
247 |
} catch (Exception e) { |
248 |
e.printStackTrace(); |
249 |
} |
250 |
} |
251 |
|
252 |
/**
|
253 |
* A test
|
254 |
*/
|
255 |
public void test12() { |
256 |
try {
|
257 |
// Insert at the end
|
258 |
obj = new String("ZZ????"); |
259 |
|
260 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
261 |
|
262 |
System.out.println("Test 12:\nObj: " + obj + "\nResults: " + v2); |
263 |
} catch (Exception e) { |
264 |
e.printStackTrace(); |
265 |
} |
266 |
} |
267 |
|
268 |
/**
|
269 |
* A test
|
270 |
*/
|
271 |
public void test13() { |
272 |
try {
|
273 |
// An insertion
|
274 |
obj = new String("?and?"); |
275 |
|
276 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
277 |
|
278 |
System.out.println("Test 13:\nObj: " + obj + "\nResults: " + v2); |
279 |
} catch (Exception e) { |
280 |
e.printStackTrace(); |
281 |
} |
282 |
} |
283 |
|
284 |
/**
|
285 |
* A test
|
286 |
*/
|
287 |
public void test14() { |
288 |
try {
|
289 |
// An insertion
|
290 |
obj = new String("?AND?"); |
291 |
|
292 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
293 |
|
294 |
System.out.println("Test 14:\nObj: " + obj + "\nResults: " + v2); |
295 |
} catch (Exception e) { |
296 |
e.printStackTrace(); |
297 |
} |
298 |
} |
299 |
|
300 |
/**
|
301 |
* A test
|
302 |
*/
|
303 |
public void test15() { |
304 |
try {
|
305 |
// An insertion
|
306 |
obj = new String("appgvSIG"); |
307 |
|
308 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
309 |
|
310 |
System.out.println("Test 15:\nObj: " + obj + "\nResults: " + v2); |
311 |
} catch (Exception e) { |
312 |
e.printStackTrace(); |
313 |
} |
314 |
} |
315 |
|
316 |
/**
|
317 |
* A test
|
318 |
*/
|
319 |
public void test16() { |
320 |
try {
|
321 |
// An insertion
|
322 |
obj = new String("libIverUtiles"); |
323 |
|
324 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
325 |
|
326 |
System.out.println("Test 16:\nObj: " + obj + "\nResults: " + v2); |
327 |
} catch (Exception e) { |
328 |
e.printStackTrace(); |
329 |
} |
330 |
} |
331 |
|
332 |
/**
|
333 |
* A test
|
334 |
*/
|
335 |
public void test17() { |
336 |
try {
|
337 |
// An insertion
|
338 |
obj = new String("libUI"); |
339 |
|
340 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
341 |
|
342 |
System.out.println("Test 17:\nObj: " + obj + "\nResults: " + v2); |
343 |
} catch (Exception e) { |
344 |
e.printStackTrace(); |
345 |
} |
346 |
} |
347 |
|
348 |
/**
|
349 |
* A test
|
350 |
*/
|
351 |
public void test18() { |
352 |
try {
|
353 |
// An insertion
|
354 |
obj = new String("libIverUtiles"); |
355 |
|
356 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
357 |
|
358 |
System.out.println("Test 18:\nObj: " + obj + "\nResults: " + v2); |
359 |
} catch (Exception e) { |
360 |
e.printStackTrace(); |
361 |
} |
362 |
} |
363 |
|
364 |
/**
|
365 |
* A test
|
366 |
*/
|
367 |
public void test19() { |
368 |
try {
|
369 |
// An insertion
|
370 |
obj = new String("extWFS"); |
371 |
|
372 |
VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator); |
373 |
|
374 |
System.out.println("Test 19:\nObj: " + obj + "\nResults: " + v2); |
375 |
} catch (Exception e) { |
376 |
e.printStackTrace(); |
377 |
} |
378 |
} |
379 |
|
380 |
///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) /////
|
381 |
} |