Revision 44229

View differences:

tags/org.gvsig.desktop-2.0.243/org.gvsig.desktop.library/org.gvsig.utils/pom.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4
  <modelVersion>4.0.0</modelVersion>
5
  <artifactId>org.gvsig.utils</artifactId>
6
  <packaging>jar</packaging>
7
  <name>${project.artifactId}</name>
8
  <parent>
9
      <groupId>org.gvsig</groupId>
10
      <artifactId>org.gvsig.desktop.library</artifactId>
11
      <version>2.0.243</version>
12
  </parent>
13

  
14
  <dependencies>
15
    <dependency>
16
        <groupId>org.gvsig</groupId>
17
        <artifactId>org.gvsig.tools.lib</artifactId>
18
        <scope>compile</scope>
19
    </dependency>
20
    <dependency>
21
        <groupId>org.gvsig</groupId>
22
        <artifactId>org.gvsig.tools.swing.api</artifactId>
23
        <scope>compile</scope>
24
    </dependency>
25
    <dependency>
26
        <groupId>org.gvsig</groupId>
27
        <artifactId>org.gvsig.tools.lib</artifactId>
28
        <type>test-jar</type>
29
        <scope>test</scope>
30
    </dependency>
31
    <dependency>
32
      <groupId>castor</groupId>
33
      <artifactId>castor</artifactId>
34
      <scope>compile</scope>
35
    </dependency>  
36
  </dependencies>
37

  
38
  <build>
39
    
40
    <!-- TODO: MAKE TESTS WORK AND REMOVE THIS OPTION -->
41
    <plugins>
42
      <plugin>
43
        <groupId>org.apache.maven.plugins</groupId>
44
        <artifactId>maven-surefire-plugin</artifactId>
45
        <configuration>
46
          <skipTests>true</skipTests>
47
        </configuration>
48
      </plugin>
49

  
50
    </plugins>
51
  </build>
52

  
53
</project>
0 54

  
tags/org.gvsig.desktop-2.0.243/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestStringUtilities.java
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;
25

  
26
import org.gvsig.utils.StringUtilities;
27

  
28
import junit.framework.TestCase;
29

  
30
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
31
 *
32
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
33
 *
34
 * This program is free software; you can redistribute it and/or
35
 * modify it under the terms of the GNU General Public License
36
 * as published by the Free Software Foundation; either version 2
37
 * of the License, or (at your option) any later version.
38
 *
39
 * This program is distributed in the hope that it will be useful,
40
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
42
 * GNU General Public License for more details.
43
 *
44
 * You should have received a copy of the GNU General Public License
45
 * along with this program; if not, write to the Free Software
46
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
47
 *
48
 * For more information, contact:
49
 *
50
 *  Generalitat Valenciana
51
 *   Conselleria d'Infraestructures i Transport
52
 *   Av. Blasco Ib??ez, 50
53
 *   46010 VALENCIA
54
 *   SPAIN
55
 *
56
 *      +34 963862235
57
 *   gvsig@gva.es
58
 *      www.gvsig.gva.es
59
 *
60
 *    or
61
 *
62
 *   IVER T.I. S.A
63
 *   Salamanca 50
64
 *   46005 Valencia
65
 *   Spain
66
 *
67
 *   +34 963163400
68
 *   dac@iver.es
69
 */
70

  
71
/**
72
 * This class tests some methods of the 'StringUtilities' class
73
 * (Now only tests the methods 'numberOfOccurrencesOfSubStringInString' and 'numberOfOccurrencesOfSubStringInStringUpToPosition')
74
 * 
75
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
76
 */
77
public class TestStringUtilities extends TestCase{
78
	private String word_String;
79
	private String word_subString;
80
	private boolean case_Sensitive;
81
	private int start_position;
82
	private int end_position;
83
	
84
	/*
85
	 *  (non-Javadoc)
86
	 * @see junit.framework.TestCase#setUp()
87
	 */
88
	protected void setUp() throws Exception {
89
		super.setUp();
90
		word_String = new String();
91
		word_subString = new String();
92
		case_Sensitive = true; // By default, case sensitive		
93
	}
94

  
95
	/*
96
	 *  (non-Javadoc)
97
	 * @see junit.framework.TestCase#tearDown()
98
	 */
99
	protected void tearDown() throws Exception {
100
		super.tearDown();
101
	}
102
	
103
	/**
104
	 * A test
105
	 */
106
	public void test1() {
107
		word_String = "la casa es grande";
108
		word_subString = "a";
109
		case_Sensitive = true;
110

  
111
		System.out.print("Test1: El n?mero de ocurrencias");
112
		
113
		if (case_Sensitive)
114
			System.out.print(" con distinci?n min?sculas/may?sculas ");
115
		else
116
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
117
		
118
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
119
	}
120
	
121
	/**
122
	 * A test
123
	 */
124
	public void test2() {
125
		word_String = "la casa es grande";
126
		word_subString = "a";
127
		case_Sensitive = false;
128

  
129
		System.out.print("Test2: El n?mero de ocurrencias");
130
		
131
		if (case_Sensitive)
132
			System.out.print(" con distinci?n min?sculas/may?sculas ");
133
		else
134
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
135
		
136
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
137
	}
138

  
139
	/**
140
	 * A test
141
	 */
142
	public void test3() {
143
		word_String = "la casa es grande";
144
		word_subString = "A";
145
		case_Sensitive = true;
146

  
147
		System.out.print("Test3: El n?mero de ocurrencias");
148
		
149
		if (case_Sensitive)
150
			System.out.print(" con distinci?n min?sculas/may?sculas ");
151
		else
152
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
153
		
154
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
155
	}
156

  
157
	/**
158
	 * A test
159
	 */
160
	public void test4() {
161
		word_String = "la casa es grande";
162
		word_subString = "A";
163
		case_Sensitive = false;
164

  
165
		System.out.print("Test4: El n?mero de ocurrencias");
166
		
167
		if (case_Sensitive)
168
			System.out.print(" con distinci?n min?sculas/may?sculas ");
169
		else
170
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
171
		
172
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
173
	}
174

  
175
	/**
176
	 * A test
177
	 */
178
	public void test5() {
179
		word_String = "la casa es grande";
180
		word_subString = "z";
181
		case_Sensitive = true;
182

  
183
		System.out.print("Test5: El n?mero de ocurrencias");
184
		
185
		if (case_Sensitive)
186
			System.out.print(" con distinci?n min?sculas/may?sculas ");
187
		else
188
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
189
		
190
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
191
	}
192

  
193
	/**
194
	 * A test
195
	 */
196
	public void test6() {
197
		word_String = "la casa es grande";
198
		word_subString = "z";
199
		case_Sensitive = false;
200

  
201
		System.out.print("Test6: El n?mero de ocurrencias");
202
		
203
		if (case_Sensitive)
204
			System.out.print(" con distinci?n min?sculas/may?sculas ");
205
		else
206
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
207
		
208
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
209
	}
210
	
211
	/**
212
	 * A test
213
	 */
214
	public void test7() {
215
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
216
		word_subString = "cuatro menos dos";
217
		case_Sensitive = true;
218

  
219
		System.out.print("Test7: El n?mero de ocurrencias");
220
		
221
		if (case_Sensitive)
222
			System.out.print(" con distinci?n min?sculas/may?sculas ");
223
		else
224
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
225
		
226
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
227
	}
228
	
229
	/**
230
	 * A test
231
	 */
232
	public void test8() {
233
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
234
		word_subString = "cuatro menos Dos";
235
		case_Sensitive = true;
236

  
237
		System.out.print("Test8: El n?mero de ocurrencias");
238
		
239
		if (case_Sensitive)
240
			System.out.print(" con distinci?n min?sculas/may?sculas ");
241
		else
242
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
243
		
244
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
245
	}
246
	
247
	/**
248
	 * A test
249
	 */
250
	public void test9() {
251
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
252
		word_subString = "cuatro menos dos";
253
		case_Sensitive = false;
254

  
255
		System.out.print("Test9: El n?mero de ocurrencias");
256
		
257
		if (case_Sensitive)
258
			System.out.print(" con distinci?n min?sculas/may?sculas ");
259
		else
260
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
261
		
262
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
263
	}
264
	
265
	/**
266
	 * A test
267
	 */
268
	public void test10() {
269
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
270
		word_subString = "cuatro menos Dos";
271
		case_Sensitive = false;
272

  
273
		System.out.print("Test10: El n?mero de ocurrencias");
274
		
275
		if (case_Sensitive)
276
			System.out.print(" con distinci?n min?sculas/may?sculas ");
277
		else
278
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
279
		
280
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
281
	}
282
	
283
	/**
284
	 * A test
285
	 */
286
	public void test11() {
287
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
288
		word_subString = "cuatro menos Dos";
289
		case_Sensitive = false;
290
		start_position = 0;
291
		end_position = word_String.length();
292

  
293
		System.out.print("Test11: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
294
		
295
		if (case_Sensitive)
296
			System.out.print(" con distinci?n min?sculas/may?sculas ");
297
		else
298
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
299
		
300
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
301
	}
302
	
303
	/**
304
	 * A test
305
	 */
306
	public void test12() {
307
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
308
		word_subString = "cuatro menos dos";
309
		case_Sensitive = true;
310
		start_position = 20;
311
		end_position = 72;
312

  
313
		System.out.print("Test12: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
314
		
315
		if (case_Sensitive)
316
			System.out.print(" con distinci?n min?sculas/may?sculas ");
317
		else
318
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
319
		
320
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
321
	}
322

  
323
	/**
324
	 * A test
325
	 */
326
	public void test13() {
327
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
328
		word_subString = "cuatro menos Dos";
329
		case_Sensitive = true;
330
		start_position = 20;
331
		end_position = 72;
332

  
333
		System.out.print("Test13: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
334
		
335
		if (case_Sensitive)
336
			System.out.print(" con distinci?n min?sculas/may?sculas ");
337
		else
338
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
339
		
340
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
341
	}
342
	
343
	/**
344
	 * A test
345
	 */
346
	public void test14() {
347
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
348
		word_subString = "cuatro menos dos";
349
		case_Sensitive = false;
350
		start_position = 20;
351
		end_position = 72;
352

  
353
		System.out.print("Test14: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
354
		
355
		if (case_Sensitive)
356
			System.out.print(" con distinci?n min?sculas/may?sculas ");
357
		else
358
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
359
		
360
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
361
	}
362
	
363
	/**
364
	 * A test
365
	 */
366
	public void test15() {
367
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
368
		word_subString = "cuatro menos Dos";
369
		case_Sensitive = false;
370
		start_position = 20;
371
		end_position = 72;
372

  
373
		System.out.print("Test15: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
374
		
375
		if (case_Sensitive)
376
			System.out.print(" con distinci?n min?sculas/may?sculas ");
377
		else
378
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
379
		
380
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
381
	}
382
	
383
	/**
384
	 * A test
385
	 */
386
	public void test16() {
387
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
388
		word_subString = "cuatro menos dos";
389
		case_Sensitive = true;
390
		start_position = 21;
391
		end_position = 72;
392

  
393
		System.out.print("Test16: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
394
		
395
		if (case_Sensitive)
396
			System.out.print(" con distinci?n min?sculas/may?sculas ");
397
		else
398
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
399
		
400
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
401
	}
402

  
403
	/**
404
	 * A test
405
	 */
406
	public void test17() {
407
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
408
		word_subString = "cuatro menos Dos";
409
		case_Sensitive = true;
410
		start_position = 21;
411
		end_position = 72;
412

  
413
		System.out.print("Test17: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
414
		
415
		if (case_Sensitive)
416
			System.out.print(" con distinci?n min?sculas/may?sculas ");
417
		else
418
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
419
		
420
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
421
	}
422
	
423
	/**
424
	 * A test
425
	 */
426
	public void test18() {
427
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
428
		word_subString = "cuatro menos dos";
429
		case_Sensitive = false;
430
		start_position = 21;
431
		end_position = 72;
432

  
433
		System.out.print("Test18: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
434
		
435
		if (case_Sensitive)
436
			System.out.print(" con distinci?n min?sculas/may?sculas ");
437
		else
438
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
439
		
440
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
441
	}
442
	
443
	/**
444
	 * A test
445
	 */
446
	public void test19() {
447
		word_String = "Frasecica: tres mas cuAtro menos dos no es lo mismo que cuatro menos dos mas cinco ni que cuatro menos dos mas dos ni que cuatro menos cuatro mas diez. ?Cierto no?";
448
		word_subString = "cuatro menos Dos";
449
		case_Sensitive = false;
450
		start_position = 21;
451
		end_position = 72;
452

  
453
		System.out.print("Test19: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
454
		
455
		if (case_Sensitive)
456
			System.out.print(" con distinci?n min?sculas/may?sculas ");
457
		else
458
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
459
		
460
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
461
	}
462
}
0 463

  
tags/org.gvsig.desktop-2.0.243/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/centerComponent/TestCenterComponent.java
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.centerComponent;
25

  
26
import java.awt.Color;
27
import java.awt.Dimension;
28
import java.awt.Point;
29
import java.awt.Rectangle;
30
import java.awt.Toolkit;
31
import java.awt.event.MouseAdapter;
32
import java.awt.event.MouseEvent;
33

  
34
import javax.swing.JDesktopPane;
35
import javax.swing.JDialog;
36
import javax.swing.JFrame;
37
import javax.swing.JInternalFrame;
38
import javax.swing.JPanel;
39

  
40
import org.gvsig.utils.centerComponent.CenterComponent;
41

  
42

  
43
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
44
 *
45
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
46
 *
47
 * This program is free software; you can redistribute it and/or
48
 * modify it under the terms of the GNU General Public License
49
 * as published by the Free Software Foundation; either version 2
50
 * of the License, or (at your option) any later version.
51
 *
52
 * This program is distributed in the hope that it will be useful,
53
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
54
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
55
 * GNU General Public License for more details.
56
 *
57
 * You should have received a copy of the GNU General Public License
58
 * along with this program; if not, write to the Free Software
59
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
60
 *
61
 * For more information, contact:
62
 *
63
 *  Generalitat Valenciana
64
 *   Conselleria d'Infraestructures i Transport
65
 *   Av. Blasco Ib??ez, 50
66
 *   46010 VALENCIA
67
 *   SPAIN
68
 *
69
 *      +34 963862235
70
 *   gvsig@gva.es
71
 *      www.gvsig.gva.es
72
 *
73
 *    or
74
 *
75
 *   IVER T.I. S.A
76
 *   Salamanca 50
77
 *   46005 Valencia
78
 *   Spain
79
 *
80
 *   +34 963163400
81
 *   dac@iver.es
82
 */
83

  
84
/**
85
 * Tests the 'centerJComponent' method of the CenterJComponent class
86
 * 
87
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
88
 */
89
public class TestCenterComponent {
90
	private static JFrame jFrame;
91
	private static JDesktopPane jDesktopPane;
92
	private static int i;
93
	
94
	/**
95
	 * Test method for the CenterJComponent
96
	 * 
97
	 * @param args
98
	 */
99
	public static void main (String args[])
100
	{		
101
		try {
102
			// Creates the main JFrame and configures it for test. Adds a JDesktopPane			
103
			jFrame = new JFrame("JFrame: Tests 1, 2 y 3");
104

  
105
			jDesktopPane = new JDesktopPane();
106
			jDesktopPane.setPreferredSize(new Dimension(300, 300));
107
			jDesktopPane.setSize(new Dimension(300, 300));			
108
			jDesktopPane.addMouseListener(new MouseAdapter() {
109

  
110
				/*
111
				 *  (non-Javadoc)
112
				 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
113
				 */
114
				public void mouseClicked(MouseEvent e) {
115
					createComponentsForTest();				
116
				}
117
			});
118
			
119
			jFrame.getContentPane().add(jDesktopPane);
120
			jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
121
			jFrame.pack();
122
			jFrame.setVisible(true);
123
			
124
			// By default: centers the JFrame in the screen
125
			Point screenTopLeftCorner = new Point(0, 0);
126
			Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
127
			Rectangle screenRectangle = new Rectangle(screenTopLeftCorner, screenDimension);
128
			CenterComponent.centerComponent(jFrame, screenRectangle);
129
//			jFrame.setLocationRelativeTo(null);
130
			
131
			i = 0;
132
			createComponentsForTest();
133
		}
134
		catch(Exception e) {
135
			e.printStackTrace();
136
		}	
137
		
138
	}
139
	
140
	/**
141
	 * Creates some objects for test
142
	 */
143
	private static void createComponentsForTest() {
144
		
145
		// Creates a JInternalFrame with a JPanel, and adds it
146
		JInternalFrame jInternalFrame1 = new JInternalFrame("JInternalFrame" + i,
147
				true, // resizable
148
		        true, // closable
149
		        true, // maximizable
150
		        false); //iconizable
151
		jInternalFrame1.setPreferredSize(new Dimension(200, 200));
152
		jInternalFrame1.setSize(new Dimension(200, 200));
153
		
154
		JPanel jPanel1 = new JPanel();
155
		jPanel1.setBackground(Color.BLUE);
156
		jInternalFrame1.getContentPane().add(jPanel1);
157
		jInternalFrame1.setVisible(true);
158
		jDesktopPane.add(jInternalFrame1);				
159

  
160
		// Creates a JDialog with a JPanel, and adds it
161
		JDialog jDialog = new JDialog();
162
		jDialog.setTitle("JDialog " + i);
163
		jDialog.setSize(new Dimension(100, 150));		
164
		JPanel jPanel2 = new JPanel();
165
		jPanel2.setBackground(Color.GREEN);
166
		jDialog.getContentPane().add(jPanel2);			
167
		jDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
168
		jDialog.setVisible(true);
169
		
170
		// Centers the JInternalFrame
171
		CenterComponent.centerComponent(jInternalFrame1, jDesktopPane.getBounds());
172
		
173
		// Centers the JDialog
174
		jDialog.setLocationRelativeTo(jFrame.getContentPane());
175

  
176
		i++;
177
	}
178
}
0 179

  
tags/org.gvsig.desktop-2.0.243/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/search/TestBinarySearchUsingFirstCharacters.java
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.search;
25

  
26
import java.text.Collator;
27
import java.util.ArrayList;
28
import java.util.Collections;
29
import java.util.Comparator;
30
import java.util.List;
31
import java.util.Locale;
32
import java.util.Vector;
33

  
34
import org.gvsig.utils.CompareLists;
35
import org.gvsig.utils.StringComparator;
36
import org.gvsig.utils.search.BinarySearchUsingFirstCharacters;
37

  
38

  
39
import junit.framework.TestCase;
40

  
41
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
42
 *
43
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
44
 *
45
 * This program is free software; you can redistribute it and/or
46
 * modify it under the terms of the GNU General Public License
47
 * as published by the Free Software Foundation; either version 2
48
 * of the License, or (at your option) any later version.
49
 *
50
 * This program is distributed in the hope that it will be useful,
51
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
52
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
53
 * GNU General Public License for more details.
54
 *
55
 * You should have received a copy of the GNU General Public License
56
 * along with this program; if not, write to the Free Software
57
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
58
 *
59
 * For more information, contact:
60
 *
61
 *  Generalitat Valenciana
62
 *   Conselleria d'Infraestructures i Transport
63
 *   Av. Blasco Ib??ez, 50
64
 *   46010 VALENCIA
65
 *   SPAIN
66
 *
67
 *      +34 963862235
68
 *   gvsig@gva.es
69
 *      www.gvsig.gva.es
70
 *
71
 *    or
72
 *
73
 *   IVER T.I. S.A
74
 *   Salamanca 50
75
 *   46005 Valencia
76
 *   Spain
77
 *
78
 *   +34 963163400
79
 *   dac@iver.es
80
 */
81

  
82
/**
83
 * Tests the static methods of BinarySearchUsingFirstCharacters
84
 * 
85
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
86
 */
87
public class TestBinarySearchUsingFirstCharacters extends TestCase {
88
	private static String text;
89
	private static Vector v1;
90
	private static Vector v2;
91
	private static List list;
92
	private static List results;
93
	private static StringComparator stringComparator;
94
//	private static StringComparatorForItems stringComparatorForItems;
95
	
96
	/*
97
	 *  (non-Javadoc)
98
	 * @see junit.framework.TestCase#setUp()
99
	 */
100
	protected void setUp() throws Exception {
101
		super.setUp();
102

  
103
		// Initialize the text
104
		text = "";
105
		
106
		// Initialize the StringComparator
107
		stringComparator = new StringComparator();
108

  
109
		// Initialize the StringComparatorForItems
110
//		stringComparatorForItems = new StringComparatorForItems();
111

  
112
		// Initialize the vector of Items (for test methods without the parameter Comparator)
113
		v1 = new Vector();
114
		v1.add(new Item("extWMS"));
115
		v1.add(new Item("libUI"));
116
		v1.add(new Item("extWMS"));
117
		v1.add(new Item("libRemoteServices"));
118
		v1.add(new Item("extWFS2"));
119
		v1.add(new Item("libNomenclatorIGN"));
120
		v1.add(new Item("libNomenclatorIGN_GUI"));
121
		v1.add(new Item("libIverUtiles"));
122
		v1.add(new Item("extWFS2"));
123
		v1.add(new Item("EXTWFS2"));
124
		v1.add(new Item("extWFS2"));
125
		v1.add(new Item("libGDBMS"));
126
		v1.add(new Item("libInternationalization"));
127
		v1.add(new Item("libFMap"));
128
		v1.add(new Item("libuiDownCase"));
129
		v1.add(new Item("6"));
130
		v1.add(new Item("4"));
131
		v1.add(new Item("3"));
132
		v1.add(new Item("5"));
133
		v1.add(new Item("2"));
134
		v1.add(new Item("1"));
135
		v1.add(new Item("extWFS2"));
136
		v1.add(new Item("libExceptions"));
137
		v1.add(new Item("libDriverManager"));
138
		v1.add(new Item("libCq CMS for java"));
139
		v1.add(new Item("libCorePlugin"));
140
		v1.add(new Item("extWFS2"));
141
		v1.add(new Item("extAddIDEELayers"));
142
		v1.add(new Item("extAlertCClient"));
143
		v1.add(new Item("extCAD"));
144
		v1.add(new Item("extWFS2"));
145
		v1.add(new Item("?and?"));
146
		v1.add(new Item("?and?"));
147
		v1.add(new Item("extJDBC"));
148
		v1.add(new Item("extMyPlugin"));
149
		v1.add(new Item("extRasterTools"));
150
		v1.add(new Item("extScripting"));
151
		v1.add(new Item("extWCS"));
152
		v1.add(new Item("extWFS2"));
153
		v1.add(new Item("extwfs2"));
154
		v1.add(new Item("extWMS"));
155
		v1.add(new Item("extWMS"));
156
		v1.add(new Item("extWCS"));
157
		v1.add(new Item("7"));
158
		v1.add(new Item("9"));
159
		v1.add(new Item("8"));
160
		v1.add(new Item("0"));
161
		v1.add(new Item("EXTWCS"));
162
		v1.add(new Item("?and?"));
163
		v1.add(new Item("extensi?n"));
164
		v1.add(new Item("?AND?"));
165
		v1.add(new Item("_fwAndami"));
166
		v1.add(new Item("abcdefghijklmn?opqrstuvwxyz"));
167
		v1.add(new Item("?"));
168
		v1.add(new Item("appgvSIG"));
169
		v1.add(new Item("la casa"));
170
		v1.add(new Item("la monta?a"));
171
		v1.add(new Item("la colina"));
172
		v1.add(new Item("las abejas"));
173
		v1.add(new Item("las nutrias"));
174
		v1.add(new Item("las ballenas"));
175
		v1.add(new Item("lasa?a"));
176
		v1.add(new Item("Vector"));
177
		v1.add(new Item("?e"));
178

  
179
		// Initialize the vector of Strings (for test methods with the parameter Comparator)
180
		v2 = new Vector();
181
		v2.add("extWMS");
182
		v2.add("libUI");
183
		v2.add("extWMS");
184
		v2.add("libRemoteServices");
185
		v2.add("extWFS2");
186
		v2.add("libNomenclatorIGN");
187
		v2.add("libNomenclatorIGN_GUI");
188
		v2.add("libIverUtiles");
189
		v2.add("extWFS2");
190
		v2.add("EXTWFS2");
191
		v2.add("extWFS2");
192
		v2.add("libGDBMS");
193
		v2.add("libInternationalization");
194
		v2.add("libFMap");
195
		v2.add("libuiDownCase");
196
		v2.add("6");
197
		v2.add("4");
198
		v2.add("3");
199
		v2.add("5");
200
		v2.add("2");
201
		v2.add("1");
202
		v2.add("extWFS2");
203
		v2.add("libExceptions");
204
		v2.add("libDriverManager");
205
		v2.add("libCq CMS for java");
206
		v2.add("libCorePlugin");
207
		v2.add("extWFS2");
208
		v2.add("extAddIDEELayers");
209
		v2.add("extAlertCClient");
210
		v2.add("extCAD");
211
		v2.add("extWFS2");
212
		v2.add("?and?");
213
		v2.add("?and?");
214
		v2.add("extJDBC");
215
		v2.add("extMyPlugin");
216
		v2.add("extRasterTools");
217
		v2.add("extScripting");
218
		v2.add("extWCS");
219
		v2.add("extWFS2");
220
		v2.add("extwfs2");
221
		v2.add("extWMS");
222
		v2.add("extWMS");
223
		v2.add("extWCS");
224
		v2.add("7");
225
		v2.add("9");
226
		v2.add("8");
227
		v2.add("0");
228
		v2.add("EXTWCS");
229
		v2.add("?and?");
230
		v2.add("extensi?n");
231
		v2.add("?AND?");
232
		v2.add("_fwAndami");
233
		v2.add("abcdefghijklmn?opqrstuvwxyz");
234
		v2.add("?");
235
		v2.add("appgvSIG");
236
		v2.add("la casa");
237
		v2.add("la monta?a");
238
		v2.add("la colina");
239
		v2.add("las abejas");
240
		v2.add("las nutrias");
241
		v2.add("las ballenas");
242
		v2.add("lasa?a");
243
		v2.add("Vector");
244
		v2.add("?e");
245
		
246
		// Sort items of the two vectors
247
		Collator collator = Collator.getInstance(new Locale("es_ES"));
248
//		stringComparatorForItems.setLocaleRules(stringComparatorForItems.new LocaleRules(true, collator));
249
//		Collections.sort(v1.subList(0, v1.size()), stringComparatorForItems);
250
		
251
		// The algorithm of sort is the default used by Java (that makes some subsets: one for numbers, one for words that starts in big letters,
252
		//   another that stats in small letters, another with 'special' characters, etc)
253
		Collections.sort(v1.subList(0, v1.size())); 
254
		
255
		stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
256
		Collections.sort(v2.subList(0, v2.size()), stringComparator);
257
	}
258

  
259
	/*
260
	 *  (non-Javadoc)
261
	 * @see junit.framework.TestCase#tearDown()
262
	 */
263
	protected void tearDown() throws Exception {
264
		super.tearDown();
265
	}
266
	
267
	///// TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector) /////
268
	
269
	/**
270
	 * A test
271
	 */
272
	public void test1() {
273
		try {
274
			text = "";
275
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
276
			
277
			// List of results
278
			results = v1.subList(0, v1.size());
279
			
280
			System.out.println("Test 1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
281
			
282
			if (CompareLists.compare(list, results)) {
283
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
284
			} else {
285
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
286
				fail();
287
			}
288
		} catch (Exception e) {
289
			e.printStackTrace();
290
		}
291
	}
292
	
293
	/**
294
	 * A test
295
	 */
296
	public void test2() {
297
		try {
298
			text = "ext";
299
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive("ext", v1);
300
			
301
			// List of results
302
			results = new ArrayList();
303
			results.add(new Item("extAddIDEELayers"));
304
			results.add(new Item("extAlertCClient"));
305
			results.add(new Item("extCAD"));
306
			results.add(new Item("extJDBC"));
307
			results.add(new Item("extMyPlugin"));
308
			results.add(new Item("extRasterTools"));
309
			results.add(new Item("extScripting"));
310
			results.add(new Item("extWCS"));
311
			results.add(new Item("extWCS"));
312
			results.add(new Item("extWFS2"));
313
			results.add(new Item("extWFS2"));
314
			results.add(new Item("extWFS2"));
315
			results.add(new Item("extWFS2"));
316
			results.add(new Item("extWFS2"));
317
			results.add(new Item("extWFS2"));
318
			results.add(new Item("extWFS2"));
319
			results.add(new Item("extWMS"));
320
			results.add(new Item("extWMS"));
321
			results.add(new Item("extWMS"));
322
			results.add(new Item("extWMS"));
323
			results.add(new Item("extensi?n"));
324
			results.add(new Item("extwfs2"));
325

  
326
			System.out.println("\nTest 2:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
327
			
328
			if (CompareLists.compare(list, results)) {
329
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
330
			} else {
331
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
332
				fail();
333
			}
334
		} catch (Exception e) {
335
			e.printStackTrace();
336
		}
337
	}
338

  
339
	/**
340
	 * A test
341
	 */
342
	public void test3() {
343
		try {
344
			text = "libUI";
345
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
346
			
347
			// List of results
348
			results = new ArrayList();
349
			results.add(new Item("libUI"));
350
			
351
			System.out.println("\nTest 3:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
352
			
353
			if (CompareLists.compare(list, results)) {
354
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
355
			} else {
356
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
357
				fail();
358
			}
359
		} catch (Exception e) {
360
			e.printStackTrace();
361
		}
362
	}
363
	
364
	/**
365
	 * A test
366
	 */
367
	public void test4() {
368
		try {
369
			text = "extWFS2";
370
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
371
			
372
			// List 4 of results
373
			results = new ArrayList();
374
			results.add(new Item("extWFS2"));
375
			results.add(new Item("extWFS2"));
376
			results.add(new Item("extWFS2"));
377
			results.add(new Item("extWFS2"));
378
			results.add(new Item("extWFS2"));
379
			results.add(new Item("extWFS2"));
380
			results.add(new Item("extWFS2"));		
381
			
382
			System.out.println("\nTest 4:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
383
			
384
			if (CompareLists.compare(list, results)) {
385
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
386
			} else {
387
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
388
				fail();
389
			}
390
		} catch (Exception e) {
391
			e.printStackTrace();
392
		}
393
	}
394
	
395
	/**
396
	 * A test
397
	 */
398
	public void test5() {
399
		try {
400
			text = "extWFS2a";
401
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
402
			
403
			// List of results (without elements)
404
			results = null;
405
			
406
			System.out.println("\nTest 5:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
407
			
408
			if (CompareLists.compare(list, results)) {
409
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
410
			} else {
411
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
412
				fail();
413
			}
414
		} catch (Exception e) {
415
			e.printStackTrace();
416
		}
417
	}
418
	
419
	/**
420
	 * A test
421
	 */
422
	public void test6() {
423
		try {
424
			text = "?and?";
425
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
426
			
427
			// List of results
428
			results = new ArrayList();
429
			results.add(new Item("?and?"));
430
			
431
			System.out.println("\nTest 6:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
432
			
433
			if (CompareLists.compare(list, results)) {
434
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
435
			} else {
436
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
437
				fail();
438
			}
439
		} catch (Exception e) {
440
			e.printStackTrace();
441
		}
442
	}
443
	
444
	/**
445
	 * A test
446
	 */
447
	public void test7() {
448
		try {
449
			text = "?AND?";
450
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
451
			
452
			// List of results
453
			results = new ArrayList();
454
			results.add(new Item("?AND?"));
455
			
456
			System.out.println("\nTest 7:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
457
			
458
			if (CompareLists.compare(list, results)) {
459
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
460
			} else {
461
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
462
				fail();
463
			}
464
		} catch (Exception e) {
465
			e.printStackTrace();
466
		}
467
	}
468
	
469
	/**
470
	 * A test
471
	 */
472
	public void test8() {
473
		try {
474
			text = "la ";
475
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
476
	
477
			// List of results
478
			results = new ArrayList();
479
			results.add(new Item("la casa"));
480
			results.add(new Item("la colina"));
481
			results.add(new Item("la monta?a"));
482
			
483
			System.out.println("\nTest 8:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
484
			
485
			if (CompareLists.compare(list, results)) {
486
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
487
			} else {
488
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
489
				fail();
490
			}
491
		} catch (Exception e) {
492
			e.printStackTrace();
493
		}
494
	}
495
	
496
	/**
497
	 * A test
498
	 */
499
	public void test9() {
500
		try {
501
			text = "livUI";
502
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
503
			
504
			// List of results (without elements)
505
			results = null;
506
			
507
			System.out.println("\nTest 9:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
508
			
509
			if (CompareLists.compare(list, results)) {
510
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
511
			} else {
512
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
513
				fail();
514
			}
515
		} catch (Exception e) {
516
			e.printStackTrace();
517
		}
518
	}
519
	
520
	/**
521
	 * A test
522
	 */
523
	public void test9_1() {
524
		try {
525
			text = "libui";
526
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
527
			
528
			// List of results (without elements)
529
			results = new ArrayList();
530
			results.add(new Item("libuiDownCase"));
531
			
532
			System.out.println("\nTest 9_1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
533
			
534
			if (CompareLists.compare(list, results)) {
535
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
536
			} else {
537
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
538
				fail();
539
			}
540
		} catch (Exception e) {
541
			e.printStackTrace();
542
		}
543
	}
544
	
545
	/**
546
	 * A test
547
	 */
548
	public void test10() {
549
		try {
550
			text = "?";
551
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
552
			
553
			// List of results (without elements)
554
			results = new ArrayList();
555
			results.add(new Item("?"));
556
			
557
			System.out.println("\nTest 10:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
558
			
559
			if (CompareLists.compare(list, results)) {
560
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
561
			} else {
562
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
563
				fail();
564
			}
565
		} catch (Exception e) {
566
			e.printStackTrace();
567
		}
568
	}
569
	///// END TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector) /////
570
	
571
	///// TEST OPERATION: doSearchWithoutConsideringCaseSensitive(String, Vector) /////
572
	
573
	/**
574
	 * A test
575
	 */
576
	public void test11() {
577
		try {
578
			text = "";
579
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
580
			
581
			// List of results
582
			results = v1.subList(0, v1.size());
583
				
584
			System.out.println("\nTest 11:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
585
				
586
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
587
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
588
			} else {
589
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
590
				fail();
591
			}
592
		} catch (Exception e) {
593
			e.printStackTrace();
594
		}
595
	}
596
	
597
	/**
598
	 * A test
599
	 */
600
	public void test12() {
601
		try {
602
			text = "ext";
603
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
604
			
605
			// List of results
606
			results = new ArrayList();
607
			results.add(new Item("extAddIDEELayers"));
608
			results.add(new Item("extAlertCClient"));
609
			results.add(new Item("extCAD"));
610
			results.add(new Item("extJDBC"));
611
			results.add(new Item("extMyPlugin"));
612
			results.add(new Item("extRasterTools"));
613
			results.add(new Item("extScripting"));
614
			results.add(new Item("extWCS"));
615
			results.add(new Item("extWCS"));
616
			results.add(new Item("extWFS2"));
617
			results.add(new Item("extWFS2"));
618
			results.add(new Item("extWFS2"));
619
			results.add(new Item("extWFS2"));
620
			results.add(new Item("extWFS2"));
621
			results.add(new Item("extWFS2"));
622
			results.add(new Item("extWFS2"));
623
			results.add(new Item("extWMS"));
624
			results.add(new Item("extWMS"));
625
			results.add(new Item("extWMS"));
626
			results.add(new Item("extWMS"));
627
			results.add(new Item("extensi?n"));
628
			results.add(new Item("extwfs2"));
629
							
630
			System.out.println("Test 12:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
631
				
632
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
633
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
634
			} else {
635
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
636
				fail();
637
			}
638
		} catch (Exception e) {
639
			e.printStackTrace();
640
		}
641
	}
642
	
643
	/**
644
	 * A test
645
	 */
646
	public void test13() {
647
		try {
648
			text = "libUI";
649
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
650

  
651
			// List of results
652
			results = new ArrayList();
653
			results.add(new Item("libUI"));
654
			results.add(new Item("libuiDownCase"));
655
					
656
			System.out.println("Test 13:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
657
				
658
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
659
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
660
			} else {
661
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
662
				fail();
663
			}
664
		} catch (Exception e) {
665
			e.printStackTrace();
666
		}
667
	}
668
	
669
	/**
670
	 * A test
671
	 */
672
	public void test14() {
673
		try {
674
			text = "extWFS2";
675
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
676
			
677
			// List of results
678
			results = new ArrayList();
679
			results.add(new Item("extWFS2"));
680
			results.add(new Item("extWFS2"));
681
			results.add(new Item("extWFS2"));
682
			results.add(new Item("extWFS2"));
683
			results.add(new Item("extWFS2"));
684
			results.add(new Item("extWFS2"));
685
			results.add(new Item("extWFS2"));
686
			results.add(new Item("extwfs2"));
687

  
688
			System.out.println("Test 14:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
689
				
690
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
691
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
692
			} else {
693
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
694
				fail();
695
			}
696
		} catch (Exception e) {
697
			e.printStackTrace();
698
		}
699
	}
700
	
701
	/**
702
	 * A test
703
	 */
704
	public void test15() {
705
		try {
706
			text = "extWFS2a";
707
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
708
			
709
			// List of results (without elements)
710
			results = null;
711
							
712
			System.out.println("Test 15:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
713
				
714
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
715
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
716
			} else {
717
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
718
				fail();
719
			}
720
		} catch (Exception e) {
721
			e.printStackTrace();
722
		}
723
	}
724
	
725
	/**
726
	 * A test
727
	 */
728
	public void test16() {
729
		try {
730
			text = "?";
731
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
732
			
733
			// List of results
734
			results = new ArrayList();
735
			results.add(new Item("?e"));
736
			results.add(new Item("?"));
737
					
738
			System.out.println("Test 16:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
739
				
740
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
741
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
742
			} else {
743
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
744
				fail();
745
			}
746
		} catch (Exception e) {
747
			e.printStackTrace();
748
		}
749
	}
750
	
751
	/**
752
	 * A test
753
	 */
754
	public void test17() {
755
		try {
756
			text = "La ";
757
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
758
			
759
			// List of results
760
			results = new ArrayList();
761
			results.add(new Item("la casa"));
762
			results.add(new Item("la colina"));
763
			results.add(new Item("la monta?a"));
764

  
765
			System.out.println("Test 17:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
766
				
767
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
768
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
769
			} else {
770
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff