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