Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libIverUtiles / src-test / com / iver / utiles / vectorUtilities / TestVectorUtilities.java @ 11748

History | View | Annotate | Download (7.92 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
            // Set spanish rules and with case sensitive
74
                Collator collator = Collator.getInstance(new Locale("es_ES"));                
75
                stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
76
        }
77

    
78
        /*
79
         *  (non-Javadoc)
80
         * @see junit.framework.TestCase#tearDown()
81
         */
82
        protected void tearDown() throws Exception {
83
                super.tearDown();
84
        }
85

    
86
        ///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) /////
87

    
88
        /**
89
         * A test
90
         */
91
        public void test1() {
92
                try {
93
                        // Insert at the beginning
94
                        obj = new String("First");
95
                        
96
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
97
                        
98
                        System.out.println("Test 1:\nObj: " + obj + "\nResults: " + v1);
99
                } catch (Exception e) {
100
                        e.printStackTrace();
101
                }
102
        }
103
        
104
        /**
105
         * A test
106
         */
107
        public void test2() {
108
                try {
109
                        // Insert at the end
110
                        obj = new String("ZZ????");
111
                        
112
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
113
                        
114
                        System.out.println("Test 2:\nObj: " + obj + "\nResults: " + v1);
115
                } catch (Exception e) {
116
                        e.printStackTrace();
117
                }
118
        }
119
        
120
        /**
121
         * A test
122
         */
123
        public void test3() {
124
                try {
125
                        // An insertion
126
                        obj = new String("?and?");
127
                        
128
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
129
                        
130
                        System.out.println("Test 3:\nObj: " + obj + "\nResults: " + v1);
131
                } catch (Exception e) {
132
                        e.printStackTrace();
133
                }
134
        }
135
        
136
        /**
137
         * A test
138
         */
139
        public void test4() {
140
                try {
141
                        // An insertion
142
                        obj = new String("?AND?");
143
                        
144
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
145
                        
146
                        System.out.println("Test 4:\nObj: " + obj + "\nResults: " + v1);
147
                } catch (Exception e) {
148
                        e.printStackTrace();
149
                }
150
        }
151
        
152
        /**
153
         * A test
154
         */
155
        public void test5() {
156
                try {
157
                        // An insertion
158
                        obj = new String("appgvSIG");
159
                        
160
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
161
                        
162
                        System.out.println("Test 5:\nObj: " + obj + "\nResults: " + v1);
163
                } catch (Exception e) {
164
                        e.printStackTrace();
165
                }
166
        }
167
        
168
        /**
169
         * A test
170
         */
171
        public void test6() {
172
                try {
173
                        // An insertion
174
                        obj = new String("libIverUtiles");
175
                        
176
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
177
                        
178
                        System.out.println("Test 6:\nObj: " + obj + "\nResults: " + v1);
179
                } catch (Exception e) {
180
                        e.printStackTrace();
181
                }
182
        }
183

    
184
        /**
185
         * A test
186
         */
187
        public void test7() {
188
                try {
189
                        // An insertion
190
                        obj = new String("libUI");
191
                        
192
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
193
                        
194
                        System.out.println("Test 7:\nObj: " + obj + "\nResults: " + v1);
195
                } catch (Exception e) {
196
                        e.printStackTrace();
197
                }
198
        }
199
        
200
        /**
201
         * A test
202
         */
203
        public void test8() {
204
                try {
205
                        // An insertion
206
                        obj = new String("libIverUtiles");
207
                        
208
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
209
                        
210
                        System.out.println("Test 8:\nObj: " + obj + "\nResults: " + v1);
211
                } catch (Exception e) {
212
                        e.printStackTrace();
213
                }
214
        }
215
                
216
        /**
217
         * A test
218
         */
219
        public void test9() {
220
                try {
221
                        // An insertion
222
                        obj = new String("extWFS");
223
                        
224
                        VectorUtilities.addAlphabeticallyOrdered(v1, obj);
225
                        
226
                        System.out.println("Test 9:\nObj: " + obj + "\nResults: " + v1);
227
                } catch (Exception e) {
228
                        e.printStackTrace();
229
                }
230
        }
231
        ///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) /////
232
        
233
        ///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) /////
234
        
235
        /**
236
         * A test
237
         */
238
        public void test11() {
239
                try {
240
                        // Insert at the beginning
241
                        obj = new String("First");
242
                        
243
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
244
                        
245
                        System.out.println("Test 11:\nObj: " + obj + "\nResults: " + v2);
246
                } catch (Exception e) {
247
                        e.printStackTrace();
248
                }
249
        }
250
        
251
        /**
252
         * A test
253
         */
254
        public void test12() {
255
                try {
256
                        // Insert at the end
257
                        obj = new String("ZZ????");
258
                        
259
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
260
                        
261
                        System.out.println("Test 12:\nObj: " + obj + "\nResults: " + v2);
262
                } catch (Exception e) {
263
                        e.printStackTrace();
264
                }
265
        }
266
        
267
        /**
268
         * A test
269
         */
270
        public void test13() {
271
                try {
272
                        // An insertion
273
                        obj = new String("?and?");
274
                        
275
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
276
                        
277
                        System.out.println("Test 13:\nObj: " + obj + "\nResults: " + v2);
278
                } catch (Exception e) {
279
                        e.printStackTrace();
280
                }
281
        }
282
        
283
        /**
284
         * A test
285
         */
286
        public void test14() {
287
                try {
288
                        // An insertion
289
                        obj = new String("?AND?");
290
                        
291
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
292
                        
293
                        System.out.println("Test 14:\nObj: " + obj + "\nResults: " + v2);
294
                } catch (Exception e) {
295
                        e.printStackTrace();
296
                }
297
        }
298
        
299
        /**
300
         * A test
301
         */
302
        public void test15() {
303
                try {
304
                        // An insertion
305
                        obj = new String("appgvSIG");
306
                        
307
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
308
                        
309
                        System.out.println("Test 15:\nObj: " + obj + "\nResults: " + v2);
310
                } catch (Exception e) {
311
                        e.printStackTrace();
312
                }
313
        }
314
        
315
        /**
316
         * A test
317
         */
318
        public void test16() {
319
                try {
320
                        // An insertion
321
                        obj = new String("libIverUtiles");
322
                        
323
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
324
                        
325
                        System.out.println("Test 16:\nObj: " + obj + "\nResults: " + v2);
326
                } catch (Exception e) {
327
                        e.printStackTrace();
328
                }
329
        }
330

    
331
        /**
332
         * A test
333
         */
334
        public void test17() {
335
                try {
336
                        // An insertion
337
                        obj = new String("libUI");
338
                        
339
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
340
                        
341
                        System.out.println("Test 17:\nObj: " + obj + "\nResults: " + v2);
342
                } catch (Exception e) {
343
                        e.printStackTrace();
344
                }
345
        }
346
        
347
        /**
348
         * A test
349
         */
350
        public void test18() {
351
                try {
352
                        // An insertion
353
                        obj = new String("libIverUtiles");
354
                        
355
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
356
                        
357
                        System.out.println("Test 18:\nObj: " + obj + "\nResults: " + v2);
358
                } catch (Exception e) {
359
                        e.printStackTrace();
360
                }
361
        }
362
                
363
        /**
364
         * A test
365
         */
366
        public void test19() {
367
                try {
368
                        // An insertion
369
                        obj = new String("extWFS");
370
                        
371
                        VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
372
                        
373
                        System.out.println("Test 19:\nObj: " + obj + "\nResults: " + v2);
374
                } catch (Exception e) {
375
                        e.printStackTrace();
376
                }
377
        }
378
        
379
        ///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) /////
380
}