Revision 38345

View differences:

tags/v2_0_0_Build_2047/libraries/libIverUtiles/libIverUtiles/src-test/org/gvsig/utils/TestStringUtilities.java
1
package org.gvsig.utils;
2

  
3
import org.gvsig.utils.StringUtilities;
4

  
5
import junit.framework.TestCase;
6

  
7
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8
 *
9
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
10
 *
11
 * This program is free software; you can redistribute it and/or
12
 * modify it under the terms of the GNU General Public License
13
 * as published by the Free Software Foundation; either version 2
14
 * of the License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU General Public License
22
 * along with this program; if not, write to the Free Software
23
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
24
 *
25
 * For more information, contact:
26
 *
27
 *  Generalitat Valenciana
28
 *   Conselleria d'Infraestructures i Transport
29
 *   Av. Blasco Ib??ez, 50
30
 *   46010 VALENCIA
31
 *   SPAIN
32
 *
33
 *      +34 963862235
34
 *   gvsig@gva.es
35
 *      www.gvsig.gva.es
36
 *
37
 *    or
38
 *
39
 *   IVER T.I. S.A
40
 *   Salamanca 50
41
 *   46005 Valencia
42
 *   Spain
43
 *
44
 *   +34 963163400
45
 *   dac@iver.es
46
 */
47

  
48
/**
49
 * This class tests some methods of the 'StringUtilities' class
50
 * (Now only tests the methods 'numberOfOccurrencesOfSubStringInString' and 'numberOfOccurrencesOfSubStringInStringUpToPosition')
51
 * 
52
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
53
 */
54
public class TestStringUtilities extends TestCase{
55
	private String word_String;
56
	private String word_subString;
57
	private boolean case_Sensitive;
58
	private int start_position;
59
	private int end_position;
60
	
61
	/*
62
	 *  (non-Javadoc)
63
	 * @see junit.framework.TestCase#setUp()
64
	 */
65
	protected void setUp() throws Exception {
66
		super.setUp();
67
		word_String = new String();
68
		word_subString = new String();
69
		case_Sensitive = true; // By default, case sensitive		
70
	}
71

  
72
	/*
73
	 *  (non-Javadoc)
74
	 * @see junit.framework.TestCase#tearDown()
75
	 */
76
	protected void tearDown() throws Exception {
77
		super.tearDown();
78
	}
79
	
80
	/**
81
	 * A test
82
	 */
83
	public void test1() {
84
		word_String = "la casa es grande";
85
		word_subString = "a";
86
		case_Sensitive = true;
87

  
88
		System.out.print("Test1: El n?mero de ocurrencias");
89
		
90
		if (case_Sensitive)
91
			System.out.print(" con distinci?n min?sculas/may?sculas ");
92
		else
93
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
94
		
95
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
96
	}
97
	
98
	/**
99
	 * A test
100
	 */
101
	public void test2() {
102
		word_String = "la casa es grande";
103
		word_subString = "a";
104
		case_Sensitive = false;
105

  
106
		System.out.print("Test2: El n?mero de ocurrencias");
107
		
108
		if (case_Sensitive)
109
			System.out.print(" con distinci?n min?sculas/may?sculas ");
110
		else
111
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
112
		
113
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
114
	}
115

  
116
	/**
117
	 * A test
118
	 */
119
	public void test3() {
120
		word_String = "la casa es grande";
121
		word_subString = "A";
122
		case_Sensitive = true;
123

  
124
		System.out.print("Test3: El n?mero de ocurrencias");
125
		
126
		if (case_Sensitive)
127
			System.out.print(" con distinci?n min?sculas/may?sculas ");
128
		else
129
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
130
		
131
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
132
	}
133

  
134
	/**
135
	 * A test
136
	 */
137
	public void test4() {
138
		word_String = "la casa es grande";
139
		word_subString = "A";
140
		case_Sensitive = false;
141

  
142
		System.out.print("Test4: El n?mero de ocurrencias");
143
		
144
		if (case_Sensitive)
145
			System.out.print(" con distinci?n min?sculas/may?sculas ");
146
		else
147
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
148
		
149
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
150
	}
151

  
152
	/**
153
	 * A test
154
	 */
155
	public void test5() {
156
		word_String = "la casa es grande";
157
		word_subString = "z";
158
		case_Sensitive = true;
159

  
160
		System.out.print("Test5: El n?mero de ocurrencias");
161
		
162
		if (case_Sensitive)
163
			System.out.print(" con distinci?n min?sculas/may?sculas ");
164
		else
165
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
166
		
167
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
168
	}
169

  
170
	/**
171
	 * A test
172
	 */
173
	public void test6() {
174
		word_String = "la casa es grande";
175
		word_subString = "z";
176
		case_Sensitive = false;
177

  
178
		System.out.print("Test6: El n?mero de ocurrencias");
179
		
180
		if (case_Sensitive)
181
			System.out.print(" con distinci?n min?sculas/may?sculas ");
182
		else
183
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
184
		
185
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
186
	}
187
	
188
	/**
189
	 * A test
190
	 */
191
	public void test7() {
192
		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?";
193
		word_subString = "cuatro menos dos";
194
		case_Sensitive = true;
195

  
196
		System.out.print("Test7: El n?mero de ocurrencias");
197
		
198
		if (case_Sensitive)
199
			System.out.print(" con distinci?n min?sculas/may?sculas ");
200
		else
201
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
202
		
203
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
204
	}
205
	
206
	/**
207
	 * A test
208
	 */
209
	public void test8() {
210
		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?";
211
		word_subString = "cuatro menos Dos";
212
		case_Sensitive = true;
213

  
214
		System.out.print("Test8: El n?mero de ocurrencias");
215
		
216
		if (case_Sensitive)
217
			System.out.print(" con distinci?n min?sculas/may?sculas ");
218
		else
219
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
220
		
221
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
222
	}
223
	
224
	/**
225
	 * A test
226
	 */
227
	public void test9() {
228
		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?";
229
		word_subString = "cuatro menos dos";
230
		case_Sensitive = false;
231

  
232
		System.out.print("Test9: El n?mero de ocurrencias");
233
		
234
		if (case_Sensitive)
235
			System.out.print(" con distinci?n min?sculas/may?sculas ");
236
		else
237
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
238
		
239
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
240
	}
241
	
242
	/**
243
	 * A test
244
	 */
245
	public void test10() {
246
		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?";
247
		word_subString = "cuatro menos Dos";
248
		case_Sensitive = false;
249

  
250
		System.out.print("Test10: El n?mero de ocurrencias");
251
		
252
		if (case_Sensitive)
253
			System.out.print(" con distinci?n min?sculas/may?sculas ");
254
		else
255
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
256
		
257
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInString(word_String, word_subString, case_Sensitive));
258
	}
259
	
260
	/**
261
	 * A test
262
	 */
263
	public void test11() {
264
		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?";
265
		word_subString = "cuatro menos Dos";
266
		case_Sensitive = false;
267
		start_position = 0;
268
		end_position = word_String.length();
269

  
270
		System.out.print("Test11: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
271
		
272
		if (case_Sensitive)
273
			System.out.print(" con distinci?n min?sculas/may?sculas ");
274
		else
275
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
276
		
277
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
278
	}
279
	
280
	/**
281
	 * A test
282
	 */
283
	public void test12() {
284
		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?";
285
		word_subString = "cuatro menos dos";
286
		case_Sensitive = true;
287
		start_position = 20;
288
		end_position = 72;
289

  
290
		System.out.print("Test12: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
291
		
292
		if (case_Sensitive)
293
			System.out.print(" con distinci?n min?sculas/may?sculas ");
294
		else
295
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
296
		
297
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
298
	}
299

  
300
	/**
301
	 * A test
302
	 */
303
	public void test13() {
304
		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?";
305
		word_subString = "cuatro menos Dos";
306
		case_Sensitive = true;
307
		start_position = 20;
308
		end_position = 72;
309

  
310
		System.out.print("Test13: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
311
		
312
		if (case_Sensitive)
313
			System.out.print(" con distinci?n min?sculas/may?sculas ");
314
		else
315
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
316
		
317
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
318
	}
319
	
320
	/**
321
	 * A test
322
	 */
323
	public void test14() {
324
		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?";
325
		word_subString = "cuatro menos dos";
326
		case_Sensitive = false;
327
		start_position = 20;
328
		end_position = 72;
329

  
330
		System.out.print("Test14: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
331
		
332
		if (case_Sensitive)
333
			System.out.print(" con distinci?n min?sculas/may?sculas ");
334
		else
335
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
336
		
337
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
338
	}
339
	
340
	/**
341
	 * A test
342
	 */
343
	public void test15() {
344
		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?";
345
		word_subString = "cuatro menos Dos";
346
		case_Sensitive = false;
347
		start_position = 20;
348
		end_position = 72;
349

  
350
		System.out.print("Test15: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
351
		
352
		if (case_Sensitive)
353
			System.out.print(" con distinci?n min?sculas/may?sculas ");
354
		else
355
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
356
		
357
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
358
	}
359
	
360
	/**
361
	 * A test
362
	 */
363
	public void test16() {
364
		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?";
365
		word_subString = "cuatro menos dos";
366
		case_Sensitive = true;
367
		start_position = 21;
368
		end_position = 72;
369

  
370
		System.out.print("Test16: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
371
		
372
		if (case_Sensitive)
373
			System.out.print(" con distinci?n min?sculas/may?sculas ");
374
		else
375
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
376
		
377
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
378
	}
379

  
380
	/**
381
	 * A test
382
	 */
383
	public void test17() {
384
		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?";
385
		word_subString = "cuatro menos Dos";
386
		case_Sensitive = true;
387
		start_position = 21;
388
		end_position = 72;
389

  
390
		System.out.print("Test17: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
391
		
392
		if (case_Sensitive)
393
			System.out.print(" con distinci?n min?sculas/may?sculas ");
394
		else
395
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
396
		
397
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
398
	}
399
	
400
	/**
401
	 * A test
402
	 */
403
	public void test18() {
404
		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?";
405
		word_subString = "cuatro menos dos";
406
		case_Sensitive = false;
407
		start_position = 21;
408
		end_position = 72;
409

  
410
		System.out.print("Test18: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
411
		
412
		if (case_Sensitive)
413
			System.out.print(" con distinci?n min?sculas/may?sculas ");
414
		else
415
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
416
		
417
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
418
	}
419
	
420
	/**
421
	 * A test
422
	 */
423
	public void test19() {
424
		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?";
425
		word_subString = "cuatro menos Dos";
426
		case_Sensitive = false;
427
		start_position = 21;
428
		end_position = 72;
429

  
430
		System.out.print("Test19: El n?mero de ocurrencias entre posiciones " + start_position + " y " + end_position);
431
		
432
		if (case_Sensitive)
433
			System.out.print(" con distinci?n min?sculas/may?sculas ");
434
		else
435
			System.out.print(" sin distinci?n min?sculas/may?sculas ");
436
		
437
		System.out.println("de '" + word_subString + "' en '" + word_String + " es " + StringUtilities.numberOfOccurrencesOfSubStringInStringBetweenPositions(word_String, word_subString, case_Sensitive, start_position, end_position));
438
	}
439
}
0 440

  
tags/v2_0_0_Build_2047/libraries/libIverUtiles/libIverUtiles/src-test/org/gvsig/utils/centerComponent/TestCenterComponent.java
1
package org.gvsig.utils.centerComponent;
2

  
3
import java.awt.Color;
4
import java.awt.Dimension;
5
import java.awt.Point;
6
import java.awt.Rectangle;
7
import java.awt.Toolkit;
8
import java.awt.event.MouseAdapter;
9
import java.awt.event.MouseEvent;
10

  
11
import javax.swing.JDesktopPane;
12
import javax.swing.JDialog;
13
import javax.swing.JFrame;
14
import javax.swing.JInternalFrame;
15
import javax.swing.JPanel;
16

  
17
import org.gvsig.utils.centerComponent.CenterComponent;
18

  
19

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

  
61
/**
62
 * Tests the 'centerJComponent' method of the CenterJComponent class
63
 * 
64
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
65
 */
66
public class TestCenterComponent {
67
	private static JFrame jFrame;
68
	private static JDesktopPane jDesktopPane;
69
	private static int i;
70
	
71
	/**
72
	 * Test method for the CenterJComponent
73
	 * 
74
	 * @param args
75
	 */
76
	public static void main (String args[])
77
	{		
78
		try {
79
			// Creates the main JFrame and configures it for test. Adds a JDesktopPane			
80
			jFrame = new JFrame("JFrame: Tests 1, 2 y 3");
81

  
82
			jDesktopPane = new JDesktopPane();
83
			jDesktopPane.setPreferredSize(new Dimension(300, 300));
84
			jDesktopPane.setSize(new Dimension(300, 300));			
85
			jDesktopPane.addMouseListener(new MouseAdapter() {
86

  
87
				/*
88
				 *  (non-Javadoc)
89
				 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
90
				 */
91
				public void mouseClicked(MouseEvent e) {
92
					createComponentsForTest();				
93
				}
94
			});
95
			
96
			jFrame.getContentPane().add(jDesktopPane);
97
			jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
98
			jFrame.pack();
99
			jFrame.setVisible(true);
100
			
101
			// By default: centers the JFrame in the screen
102
			Point screenTopLeftCorner = new Point(0, 0);
103
			Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
104
			Rectangle screenRectangle = new Rectangle(screenTopLeftCorner, screenDimension);
105
			CenterComponent.centerComponent(jFrame, screenRectangle);
106
//			jFrame.setLocationRelativeTo(null);
107
			
108
			i = 0;
109
			createComponentsForTest();
110
		}
111
		catch(Exception e) {
112
			e.printStackTrace();
113
		}	
114
		
115
	}
116
	
117
	/**
118
	 * Creates some objects for test
119
	 */
120
	private static void createComponentsForTest() {
121
		
122
		// Creates a JInternalFrame with a JPanel, and adds it
123
		JInternalFrame jInternalFrame1 = new JInternalFrame("JInternalFrame" + i,
124
				true, // resizable
125
		        true, // closable
126
		        true, // maximizable
127
		        false); //iconizable
128
		jInternalFrame1.setPreferredSize(new Dimension(200, 200));
129
		jInternalFrame1.setSize(new Dimension(200, 200));
130
		
131
		JPanel jPanel1 = new JPanel();
132
		jPanel1.setBackground(Color.BLUE);
133
		jInternalFrame1.getContentPane().add(jPanel1);
134
		jInternalFrame1.setVisible(true);
135
		jDesktopPane.add(jInternalFrame1);				
136

  
137
		// Creates a JDialog with a JPanel, and adds it
138
		JDialog jDialog = new JDialog();
139
		jDialog.setTitle("JDialog " + i);
140
		jDialog.setSize(new Dimension(100, 150));		
141
		JPanel jPanel2 = new JPanel();
142
		jPanel2.setBackground(Color.GREEN);
143
		jDialog.getContentPane().add(jPanel2);			
144
		jDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
145
		jDialog.setVisible(true);
146
		
147
		// Centers the JInternalFrame
148
		CenterComponent.centerComponent(jInternalFrame1, jDesktopPane.getBounds());
149
		
150
		// Centers the JDialog
151
		jDialog.setLocationRelativeTo(jFrame.getContentPane());
152

  
153
		i++;
154
	}
155
}
0 156

  
tags/v2_0_0_Build_2047/libraries/libIverUtiles/libIverUtiles/src-test/org/gvsig/utils/search/TestBinarySearchUsingFirstCharacters.java
1
package org.gvsig.utils.search;
2

  
3
import java.text.Collator;
4
import java.util.ArrayList;
5
import java.util.Collections;
6
import java.util.Comparator;
7
import java.util.List;
8
import java.util.Locale;
9
import java.util.Vector;
10

  
11
import org.gvsig.utils.CompareLists;
12
import org.gvsig.utils.StringComparator;
13
import org.gvsig.utils.search.BinarySearchUsingFirstCharacters;
14

  
15

  
16
import junit.framework.TestCase;
17

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

  
59
/**
60
 * Tests the static methods of BinarySearchUsingFirstCharacters
61
 * 
62
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
63
 */
64
public class TestBinarySearchUsingFirstCharacters extends TestCase {
65
	private static String text;
66
	private static Vector v1;
67
	private static Vector v2;
68
	private static List list;
69
	private static List results;
70
	private static StringComparator stringComparator;
71
//	private static StringComparatorForItems stringComparatorForItems;
72
	
73
	/*
74
	 *  (non-Javadoc)
75
	 * @see junit.framework.TestCase#setUp()
76
	 */
77
	protected void setUp() throws Exception {
78
		super.setUp();
79

  
80
		// Initialize the text
81
		text = "";
82
		
83
		// Initialize the StringComparator
84
		stringComparator = new StringComparator();
85

  
86
		// Initialize the StringComparatorForItems
87
//		stringComparatorForItems = new StringComparatorForItems();
88

  
89
		// Initialize the vector of Items (for test methods without the parameter Comparator)
90
		v1 = new Vector();
91
		v1.add(new Item("extWMS"));
92
		v1.add(new Item("libUI"));
93
		v1.add(new Item("extWMS"));
94
		v1.add(new Item("libRemoteServices"));
95
		v1.add(new Item("extWFS2"));
96
		v1.add(new Item("libNomenclatorIGN"));
97
		v1.add(new Item("libNomenclatorIGN_GUI"));
98
		v1.add(new Item("libIverUtiles"));
99
		v1.add(new Item("extWFS2"));
100
		v1.add(new Item("EXTWFS2"));
101
		v1.add(new Item("extWFS2"));
102
		v1.add(new Item("libGDBMS"));
103
		v1.add(new Item("libInternationalization"));
104
		v1.add(new Item("libFMap"));
105
		v1.add(new Item("libuiDownCase"));
106
		v1.add(new Item("6"));
107
		v1.add(new Item("4"));
108
		v1.add(new Item("3"));
109
		v1.add(new Item("5"));
110
		v1.add(new Item("2"));
111
		v1.add(new Item("1"));
112
		v1.add(new Item("extWFS2"));
113
		v1.add(new Item("libExceptions"));
114
		v1.add(new Item("libDriverManager"));
115
		v1.add(new Item("libCq CMS for java"));
116
		v1.add(new Item("libCorePlugin"));
117
		v1.add(new Item("extWFS2"));
118
		v1.add(new Item("extAddIDEELayers"));
119
		v1.add(new Item("extAlertCClient"));
120
		v1.add(new Item("extCAD"));
121
		v1.add(new Item("extWFS2"));
122
		v1.add(new Item("?and?"));
123
		v1.add(new Item("?and?"));
124
		v1.add(new Item("extJDBC"));
125
		v1.add(new Item("extMyPlugin"));
126
		v1.add(new Item("extRasterTools"));
127
		v1.add(new Item("extScripting"));
128
		v1.add(new Item("extWCS"));
129
		v1.add(new Item("extWFS2"));
130
		v1.add(new Item("extwfs2"));
131
		v1.add(new Item("extWMS"));
132
		v1.add(new Item("extWMS"));
133
		v1.add(new Item("extWCS"));
134
		v1.add(new Item("7"));
135
		v1.add(new Item("9"));
136
		v1.add(new Item("8"));
137
		v1.add(new Item("0"));
138
		v1.add(new Item("EXTWCS"));
139
		v1.add(new Item("?and?"));
140
		v1.add(new Item("extensi?n"));
141
		v1.add(new Item("?AND?"));
142
		v1.add(new Item("_fwAndami"));
143
		v1.add(new Item("abcdefghijklmn?opqrstuvwxyz"));
144
		v1.add(new Item("?"));
145
		v1.add(new Item("appgvSIG"));
146
		v1.add(new Item("la casa"));
147
		v1.add(new Item("la monta?a"));
148
		v1.add(new Item("la colina"));
149
		v1.add(new Item("las abejas"));
150
		v1.add(new Item("las nutrias"));
151
		v1.add(new Item("las ballenas"));
152
		v1.add(new Item("lasa?a"));
153
		v1.add(new Item("Vector"));
154
		v1.add(new Item("?e"));
155

  
156
		// Initialize the vector of Strings (for test methods with the parameter Comparator)
157
		v2 = new Vector();
158
		v2.add("extWMS");
159
		v2.add("libUI");
160
		v2.add("extWMS");
161
		v2.add("libRemoteServices");
162
		v2.add("extWFS2");
163
		v2.add("libNomenclatorIGN");
164
		v2.add("libNomenclatorIGN_GUI");
165
		v2.add("libIverUtiles");
166
		v2.add("extWFS2");
167
		v2.add("EXTWFS2");
168
		v2.add("extWFS2");
169
		v2.add("libGDBMS");
170
		v2.add("libInternationalization");
171
		v2.add("libFMap");
172
		v2.add("libuiDownCase");
173
		v2.add("6");
174
		v2.add("4");
175
		v2.add("3");
176
		v2.add("5");
177
		v2.add("2");
178
		v2.add("1");
179
		v2.add("extWFS2");
180
		v2.add("libExceptions");
181
		v2.add("libDriverManager");
182
		v2.add("libCq CMS for java");
183
		v2.add("libCorePlugin");
184
		v2.add("extWFS2");
185
		v2.add("extAddIDEELayers");
186
		v2.add("extAlertCClient");
187
		v2.add("extCAD");
188
		v2.add("extWFS2");
189
		v2.add("?and?");
190
		v2.add("?and?");
191
		v2.add("extJDBC");
192
		v2.add("extMyPlugin");
193
		v2.add("extRasterTools");
194
		v2.add("extScripting");
195
		v2.add("extWCS");
196
		v2.add("extWFS2");
197
		v2.add("extwfs2");
198
		v2.add("extWMS");
199
		v2.add("extWMS");
200
		v2.add("extWCS");
201
		v2.add("7");
202
		v2.add("9");
203
		v2.add("8");
204
		v2.add("0");
205
		v2.add("EXTWCS");
206
		v2.add("?and?");
207
		v2.add("extensi?n");
208
		v2.add("?AND?");
209
		v2.add("_fwAndami");
210
		v2.add("abcdefghijklmn?opqrstuvwxyz");
211
		v2.add("?");
212
		v2.add("appgvSIG");
213
		v2.add("la casa");
214
		v2.add("la monta?a");
215
		v2.add("la colina");
216
		v2.add("las abejas");
217
		v2.add("las nutrias");
218
		v2.add("las ballenas");
219
		v2.add("lasa?a");
220
		v2.add("Vector");
221
		v2.add("?e");
222
		
223
		// Sort items of the two vectors
224
		Collator collator = Collator.getInstance(new Locale("es_ES"));
225
//		stringComparatorForItems.setLocaleRules(stringComparatorForItems.new LocaleRules(true, collator));
226
//		Collections.sort(v1.subList(0, v1.size()), stringComparatorForItems);
227
		
228
		// 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,
229
		//   another that stats in small letters, another with 'special' characters, etc)
230
		Collections.sort(v1.subList(0, v1.size())); 
231
		
232
		stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
233
		Collections.sort(v2.subList(0, v2.size()), stringComparator);
234
	}
235

  
236
	/*
237
	 *  (non-Javadoc)
238
	 * @see junit.framework.TestCase#tearDown()
239
	 */
240
	protected void tearDown() throws Exception {
241
		super.tearDown();
242
	}
243
	
244
	///// TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector) /////
245
	
246
	/**
247
	 * A test
248
	 */
249
	public void test1() {
250
		try {
251
			text = "";
252
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v1);
253
			
254
			// List of results
255
			results = v1.subList(0, v1.size());
256
			
257
			System.out.println("Test 1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
258
			
259
			if (CompareLists.compare(list, results)) {
260
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
261
			} else {
262
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
263
				fail();
264
			}
265
		} catch (Exception e) {
266
			e.printStackTrace();
267
		}
268
	}
269
	
270
	/**
271
	 * A test
272
	 */
273
	public void test2() {
274
		try {
275
			text = "ext";
276
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive("ext", v1);
277
			
278
			// List of results
279
			results = new ArrayList();
280
			results.add(new Item("extAddIDEELayers"));
281
			results.add(new Item("extAlertCClient"));
282
			results.add(new Item("extCAD"));
283
			results.add(new Item("extJDBC"));
284
			results.add(new Item("extMyPlugin"));
285
			results.add(new Item("extRasterTools"));
286
			results.add(new Item("extScripting"));
287
			results.add(new Item("extWCS"));
288
			results.add(new Item("extWCS"));
289
			results.add(new Item("extWFS2"));
290
			results.add(new Item("extWFS2"));
291
			results.add(new Item("extWFS2"));
292
			results.add(new Item("extWFS2"));
293
			results.add(new Item("extWFS2"));
294
			results.add(new Item("extWFS2"));
295
			results.add(new Item("extWFS2"));
296
			results.add(new Item("extWMS"));
297
			results.add(new Item("extWMS"));
298
			results.add(new Item("extWMS"));
299
			results.add(new Item("extWMS"));
300
			results.add(new Item("extensi?n"));
301
			results.add(new Item("extwfs2"));
302

  
303
			System.out.println("\nTest 2:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
304
			
305
			if (CompareLists.compare(list, results)) {
306
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> OK");
307
			} else {
308
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector) -> FAILED");
309
				fail();
310
			}
311
		} catch (Exception e) {
312
			e.printStackTrace();
313
		}
314
	}
315

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

  
628
			// List of results
629
			results = new ArrayList();
630
			results.add(new Item("libUI"));
631
			results.add(new Item("libuiDownCase"));
632
					
633
			System.out.println("Test 13:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
634
				
635
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
636
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
637
			} else {
638
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
639
				fail();
640
			}
641
		} catch (Exception e) {
642
			e.printStackTrace();
643
		}
644
	}
645
	
646
	/**
647
	 * A test
648
	 */
649
	public void test14() {
650
		try {
651
			text = "extWFS2";
652
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
653
			
654
			// List of results
655
			results = new ArrayList();
656
			results.add(new Item("extWFS2"));
657
			results.add(new Item("extWFS2"));
658
			results.add(new Item("extWFS2"));
659
			results.add(new Item("extWFS2"));
660
			results.add(new Item("extWFS2"));
661
			results.add(new Item("extWFS2"));
662
			results.add(new Item("extWFS2"));
663
			results.add(new Item("extwfs2"));
664

  
665
			System.out.println("Test 14:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
666
				
667
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
668
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
669
			} else {
670
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
671
				fail();
672
			}
673
		} catch (Exception e) {
674
			e.printStackTrace();
675
		}
676
	}
677
	
678
	/**
679
	 * A test
680
	 */
681
	public void test15() {
682
		try {
683
			text = "extWFS2a";
684
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
685
			
686
			// List of results (without elements)
687
			results = null;
688
							
689
			System.out.println("Test 15:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
690
				
691
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
692
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
693
			} else {
694
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
695
				fail();
696
			}
697
		} catch (Exception e) {
698
			e.printStackTrace();
699
		}
700
	}
701
	
702
	/**
703
	 * A test
704
	 */
705
	public void test16() {
706
		try {
707
			text = "?";
708
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
709
			
710
			// List of results
711
			results = new ArrayList();
712
			results.add(new Item("?e"));
713
			results.add(new Item("?"));
714
					
715
			System.out.println("Test 16:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
716
				
717
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
718
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
719
			} else {
720
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
721
				fail();
722
			}
723
		} catch (Exception e) {
724
			e.printStackTrace();
725
		}
726
	}
727
	
728
	/**
729
	 * A test
730
	 */
731
	public void test17() {
732
		try {
733
			text = "La ";
734
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
735
			
736
			// List of results
737
			results = new ArrayList();
738
			results.add(new Item("la casa"));
739
			results.add(new Item("la colina"));
740
			results.add(new Item("la monta?a"));
741

  
742
			System.out.println("Test 17:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
743
				
744
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
745
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
746
			} else {
747
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
748
				fail();
749
			}
750
		} catch (Exception e) {
751
			e.printStackTrace();
752
		}
753
	}
754
	
755
	/**
756
	 * A test
757
	 */
758
	public void test18() {
759
		try {
760
			text = "livUI";
761
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
762
			
763
			// List of results
764
			results = null;
765

  
766
			System.out.println("Test 18:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
767
				
768
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
769
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
770
			} else {
771
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
772
				fail();
773
			}
774
		} catch (Exception e) {
775
			e.printStackTrace();
776
		}
777
	}
778
	
779
	/**
780
	 * A test
781
	 */
782
	public void test18_1() {
783
		try {
784
			text = "libui";
785
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
786
			
787
			// List of results
788
			results = new ArrayList();
789
			results.add(new Item("libUI"));
790
			results.add(new Item("libuiDownCase"));
791

  
792
			System.out.println("Test 18_1:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
793
				
794
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
795
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
796
			} else {
797
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
798
				fail();
799
			}
800
		} catch (Exception e) {
801
			e.printStackTrace();
802
		}
803
	}
804
	
805
	/**
806
	 * A test
807
	 */
808
	public void test19() {
809
		try {
810
			text = "?AND?";
811
			list = BinarySearchUsingFirstCharacters.doSearchIgnoringCaseSensitive(text, v1);
812
			
813
			// List of results
814
			results = new ArrayList();
815
			results.add(new Item("?AND?"));
816
			results.add(new Item("?and?"));
817
			results.add(new Item("?and?"));
818
			results.add(new Item("?and?"));
819

  
820
			System.out.println("Test 19:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
821
				
822
			if (CompareLists.compareIgnoringCaseSensitive(list, results)) {
823
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> OK");
824
			} else {
825
				System.out.println("Op: doSearchIgnoringCaseSensitive(String, Vector) -> FAILED");
826
				fail();
827
			}
828
		} catch (Exception e) {
829
			e.printStackTrace();
830
		}
831
	}
832

  
833
	///// END TEST OPERATION: doSearchWithoutConsideringCaseSensitive(String, Vector) /////
834
	
835
	///// TEST OPERATION: doSearchConsideringCaseSensitive(String, Vector, Comparator) /////
836
	/**
837
	 * A test
838
	 */
839
	public void test21() {
840
		try {
841
			text = "";
842
			stringComparator.setCaseSensitive(true);
843
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
844
			
845
			// List of results
846
			results = v2.subList(0, v2.size());
847

  
848
			System.out.println("Test 21:\nText: " + text + "\nResults of the search: " + list + "\nResults expected: " + results);
849
			
850
			if (CompareLists.compare(list, results, stringComparator)) {
851
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> OK");
852
			} else {
853
				System.out.println("Op: doSearchConsideringCaseSensitive(String, Vector, Comparator) -> FAILED");
854
				fail();
855
			}
856
		} catch (Exception e) {
857
			e.printStackTrace();
858
		}
859
	}
860
	
861
	/**
862
	 * A test
863
	 */
864
	public void test22() {
865
		try {
866
			text = "ext";
867
			stringComparator.setCaseSensitive(true);
868
			list = BinarySearchUsingFirstCharacters.doSearchConsideringCaseSensitive(text, v2, stringComparator);
869
			
870
			// List of results
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff