Revision 39249

View differences:

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

  
42
/* CVS MESSAGES:
43
*
44
* $Id$
45
* $Log$
46
* Revision 1.7  2007-03-05 11:15:43  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.6  2007/03/05 10:03:12  jaume
50
* *** empty log message ***
51
*
52
* Revision 1.5  2007/03/05 09:00:11  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.4  2007/03/02 13:35:56  jaume
56
* *** empty log message ***
57
*
58
* Revision 1.3  2007/03/02 13:27:32  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.2  2007/03/02 13:24:53  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.1  2007/03/02 13:23:50  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.1  2006/08/29 06:18:17  jaume
68
* *** empty log message ***
69
*
70
*
71
*/
72
package org.gvsig.utils;
73

  
74
import java.io.File;
75
import java.io.FileReader;
76

  
77
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
78
import org.gvsig.utils.xmlEntity.generate.XmlTag;
79

  
80

  
81
public class TestXMLEntity extends AbstractLibraryAutoInitTestCase {
82
	private XMLEntity x1, x2, x3, x4;
83
	private XMLEntity gvp1;
84
	private XMLEntity gvp2;
85

  
86
	@Override
87
	protected void doSetUp() throws Exception {
88

  
89
		x1 = new XMLEntity();
90
		x2 = new XMLEntity();
91
		x3 = new XMLEntity();
92

  
93
		
94
		final Object obj1 = new XMLEntity();
95
		final Object obj2 = new XMLEntity();
96
		final Object obj3 = "StringClass";
97

  
98
		
99
		x1.putProperty("boolean1", false);
100
		x1.putProperty("boolean2", true);
101

  
102
		x1.putProperty("integer1", Integer.parseInt("123"));
103
		x1.putProperty("integer2", Integer.parseInt("321"));
104

  
105
		x1.putProperty("long1", Long.parseLong("123123"));
106
		x1.putProperty("long2", Long.parseLong("321321"));
107

  
108
		x1.putProperty("float1", Float.parseFloat("1234.1234"));
109
		x1.putProperty("float2", Float.parseFloat("4321.4321"));
110

  
111
		x1.putProperty("double1", Double.parseDouble("12341234.12341234"));
112
		x1.putProperty("double2", Double.parseDouble("43214321.43214321"));
113

  
114
		x1.putProperty("string1", "String1");
115
		x1.putProperty("string2", "String2");
116

  
117
		x1.putProperty("object1", obj1);
118
		x1.putProperty("object2", obj2);
119

  
120

  
121
		//----- x1 == x2
122
		x2.putProperty("boolean1", false);
123
		x2.putProperty("boolean2", true);
124

  
125
		x2.putProperty("integer1", Integer.parseInt("123"));
126
		x2.putProperty("integer2", Integer.parseInt("321"));
127

  
128
		x2.putProperty("long1", Long.parseLong("123123"));
129
		x2.putProperty("long2", Long.parseLong("321321"));
130

  
131
		x2.putProperty("float1", Float.parseFloat("1234.1234"));
132
		x2.putProperty("float2", Float.parseFloat("4321.4321"));
133

  
134
		x2.putProperty("double1", Double.parseDouble("12341234.12341234"));
135
		x2.putProperty("double2", Double.parseDouble("43214321.43214321"));
136

  
137
		x2.putProperty("string1", "String1");
138
		x2.putProperty("string2", "String2");
139

  
140
		x2.putProperty("object1", obj1);
141
		x2.putProperty("object2", obj2);
142

  
143
		
144
		//----- x1 != x3
145

  
146
		x3.putProperty("boolean1", false);
147
		x3.putProperty("boolean2", true);
148

  
149
		x3.putProperty("integer1", Integer.parseInt("123"));
150
		x3.putProperty("integer2", Integer.parseInt("321"));
151

  
152
		x3.putProperty("long1", Long.parseLong("123123"));
153
		x3.putProperty("long2", Long.parseLong("321321"));
154

  
155
		x3.putProperty("float1", Float.parseFloat("1234.1234"));
156
		x3.putProperty("float2", Float.parseFloat("4321.4321"));
157

  
158
		x3.putProperty("double1", Double.parseDouble("12341234.12341234"));
159
		x3.putProperty("double2", Double.parseDouble("43214321.43214324"));
160

  
161
		x3.putProperty("string1", "String1");
162
		x3.putProperty("string2", "String2");
163

  
164
		x3.putProperty("object1", obj1);
165
		x3.putProperty("object2", obj3);
166
		
167
		
168
		XmlTag tag;
169
		try {
170
			tag = (XmlTag) XmlTag.unmarshal(
171
					new FileReader(new File("testdata/sample.gvp")));
172
			gvp1 = new XMLEntity(tag);
173
			
174
			tag = (XmlTag) XmlTag.unmarshal(
175
					new FileReader(new File("testdata/sample2.gvp")));
176
			gvp2 = new XMLEntity(tag);
177
		} catch (Exception e) {
178
			// TODO Auto-generated catch block
179
			e.printStackTrace();
180
		}
181
		
182
		
183
		 
184
	}
185

  
186
	public void testEquality() {
187
		assertEquals(x1, x2);
188

  
189
		assertFalse(x1.equals(x3));
190
		assertFalse(x2.equals(x3));
191
	}
192

  
193
	
194
	public void testHash() {
195
		final long x1Hash = x1.hash();
196
		final long x2Hash = x2.hash();
197
		final long x3Hash = x3.hash();
198
		
199
		assertTrue("x1 should be equals to x2", x1Hash == x2Hash);
200
		assertTrue("x1 should be distinct to x3", x1Hash != x3Hash);
201
	}
202
	
203
	
204
	public void testSkippedProperties() {
205
		x1.putProperty("skipped1", true, false);
206
		x1.putProperty("skipped2", 1, false);
207
		x1.putProperty("skipped3", 1D, false);
208
		x1.putProperty("skipped4", 1F, false);
209
		x1.putProperty("skipped5", 1L, false);
210
		x1.putProperty("skipped6", "bla bla", false);
211
		
212
		x2.putProperty("skipped1", false, false);
213
		x2.putProperty("skipped2", 2, false);
214
		x2.putProperty("skipped3", 2D, false);
215
		x2.putProperty("skipped4", 2F, false);
216
		x2.putProperty("skipped5", 2L, false);
217
		x2.putProperty("skipped6", "bla bla bleitor", false);
218
		
219
		x3.putProperty("skipped1", false, false);
220
		x3.putProperty("skipped2", 2, false);
221
		x3.putProperty("skipped3", 2D, false);
222
		x3.putProperty("skipped4", 2F, false);
223
		x3.putProperty("skipped5", 2L, false);
224
		x3.putProperty("skipped6", "bla bla bleitor", false);
225

  
226
		
227
		
228
		final long x1Hash = x1.hash();
229
		final long x2Hash = x2.hash();
230
		final long x3Hash = x3.hash();
231
		
232
		assertTrue("x1 should be equals to x2", x1Hash == x2Hash);
233
		assertTrue("x1 should be distinct to x3", x1Hash != x3Hash);
234
		assertTrue("x2 should be distinct to x3", x2Hash != x3Hash);
235
		
236
		x1.remove("skipped1");
237
		x1.remove("skipped2");
238
		x1.remove("skipped3");
239
		x1.remove("skipped4");
240
		x1.remove("skipped5");
241
		x1.remove("skipped6");
242
		
243
		x2.remove("skipped1");
244
		x2.remove("skipped2");
245
		x2.remove("skipped3");
246
		x2.remove("skipped4");
247
		x2.remove("skipped5");
248
		x2.remove("skipped6");
249
		
250
		x3.remove("skipped1");
251
		x3.remove("skipped2");
252
		x3.remove("skipped3");
253
		x3.remove("skipped4");
254
		x3.remove("skipped5");
255
		x3.remove("skipped6");
256
	}
257
	
258
	
259

  
260
	public void testNonSkippedProperties() {
261
		x1.putProperty("non_skipped1", true, true);
262
		x1.putProperty("non_skipped2", 1, true);
263
		x1.putProperty("non_skipped3", 1D, true);
264
		x1.putProperty("non_skipped4", 1F, true);
265
		x1.putProperty("non_skipped5", 1L, true);
266
		x1.putProperty("non_skipped6", "bla bla", true);
267
		
268
		x3.putProperty("non_skipped1", false, true);
269
		x3.putProperty("non_skipped2", 2, true);
270
		x3.putProperty("non_skipped3", 2D, true);
271
		x3.putProperty("non_skipped4", 2F, true);
272
		x3.putProperty("non_skipped5", 2L, true);
273
		x3.putProperty("non_skipped6", "bla bla bleitor", true);
274

  
275
		x2.putProperty("non_skipped1", false, true);
276
		x2.putProperty("non_skipped2", 2, true);
277
		x2.putProperty("non_skipped3", 2D, true);
278
		x2.putProperty("non_skipped4", 2F, true);
279
		x2.putProperty("non_skipped5", 2L, true);
280
		x2.putProperty("non_skipped6", "bla bla bleitor", true);
281
		
282
		final long x1Hash = x1.hash();
283
		final long x2Hash = x2.hash();
284
		final long x3Hash = x3.hash();
285
		
286
		assertFalse("x1 should be distinct to x2", x1Hash == x2Hash);
287
		assertFalse("x1 should be distinct to x3", x1Hash == x3Hash);
288
		assertFalse("x2 should be distinct to x3", x2Hash == x3Hash);
289
		
290
		
291
		// restore the XMEntities to the initial state and ensure that
292
		// passes the tests again
293
		x1.remove("non_skipped1");
294
		x1.remove("non_skipped2");
295
		x1.remove("non_skipped3");
296
		x1.remove("non_skipped4");
297
		x1.remove("non_skipped5");
298
		x1.remove("non_skipped6");
299
		
300
		x2.remove("non_skipped1");
301
		x2.remove("non_skipped2");
302
		x2.remove("non_skipped3");
303
		x2.remove("non_skipped4");
304
		x2.remove("non_skipped5");
305
		x2.remove("non_skipped6");
306
		
307
		x3.remove("non_skipped1");
308
		x3.remove("non_skipped2");
309
		x3.remove("non_skipped3");
310
		x3.remove("non_skipped4");
311
		x3.remove("non_skipped5");
312
		x3.remove("non_skipped6");
313
		
314
		testHash();
315
		testEquality();
316
	}
317
	
318

  
319
	public void testEquivalentProjects() {
320
		final long x1Hash = gvp1.hash();
321
		final long x2Hash = gvp2.hash();
322

  
323
		assertTrue("x1 should be equals to x2", x1Hash == x2Hash);
324
	}
325
	
326
	public void testBenchMark() {
327
		long t_ini, t_unmarshal, t_buildXMLEntity, t_computeHash ;
328
		t_ini = System.currentTimeMillis();
329
		XmlTag tag;
330
		try {
331
			File f= new File("testdata/big.gvp");
332
			tag = (XmlTag) XmlTag.unmarshal(
333
					new FileReader(f));
334
			t_unmarshal = System.currentTimeMillis() - t_ini;
335
			
336
			gvp1 = new XMLEntity(tag);
337
			t_buildXMLEntity = System.currentTimeMillis() - t_unmarshal- t_ini;
338

  
339
			long hash = gvp1.hash();
340
			t_computeHash = System.currentTimeMillis() - t_buildXMLEntity- t_ini;
341
			
342
			assertTrue("BenchMark ("+f.getAbsolutePath()+" "+f.length()/1024+"Kb):" +
343
					"\t-unmarshal time: "+t_unmarshal+" milliseconds\n" +
344
					"\t-build XMLEntity time: "+t_buildXMLEntity+" milliseconds\n" +
345
					"\t-compute hash time: "+t_computeHash+" milliseconds",t_computeHash < 500);
346
			
347
		} catch (Exception e) {
348
			// TODO Auto-generated catch block
349
			e.printStackTrace();
350
		}
351
		
352
	}
353
}
0 354

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

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

  
9
import org.gvsig.utils.StringComparator;
10

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

  
52
/**
53
 * Tests the methods of the class <i>StringComparator</i>
54
 * 
55
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
56
 */
57
public class TestStringComparator {
58
	/**
59
	 * Test method for the TestMathExtension class
60
	 * 
61
	 * @param args
62
	 */
63
	public static void main(String[] args)
64
	{
65
		StringComparator stringComparator = new StringComparator();
66
		
67
		// Initialize the vector of Strings (for test methods with the parameter Comparator)
68
		Vector v = new Vector();
69
		v.add("extWMS");
70
		v.add("libUI");
71
		v.add("extWMS");
72
		v.add("libRemoteServices");
73
		v.add("extWFS2");
74
		v.add("libNomenclatorIGN");
75
		v.add("libNomenclatorIGN_GUI");
76
		v.add("libIverUtiles");
77
		v.add("extWFS2");
78
		v.add("EXTWFS2");
79
		v.add("extWFS2");
80
		v.add("libGDBMS");
81
		v.add("libInternationalization");
82
		v.add("libFMap");
83
		v.add("6");
84
		v.add("4");
85
		v.add("3");
86
		v.add("5");
87
		v.add("2");
88
		v.add("1");
89
		v.add("extWFS2");
90
		v.add("libExceptions");
91
		v.add("libDriverManager");
92
		v.add("libCq CMS for java");
93
		v.add("libCorePlugin");
94
		v.add("extWFS2");
95
		v.add("extAddIDEELayers");
96
		v.add("extAlertCClient");
97
		v.add("extCAD");
98
		v.add("extWFS2");
99
		v.add("?and?");
100
		v.add("?and?");
101
		v.add("extJDBC");
102
		v.add("extMyPlugin");
103
		v.add("extRasterTools");
104
		v.add("extScripting");
105
		v.add("extWCS");
106
		v.add("extWFS2");
107
		v.add("extwfs2");		// If both are null -> true
108
		v.add("extWMS");
109
		v.add("extWMS");
110
		v.add("extWCS");
111
		v.add("7");
112
		v.add("9");
113
		v.add("8");
114
		v.add("0");
115
		v.add("EXTWCS");
116
		v.add("?and?");
117
		v.add("extensi?n");
118
		v.add("?AND?");
119
		v.add("_fwAndami");
120
		v.add("abcdefghijklmn?opqrstuvwxyz");
121
		v.add("?");
122
		v.add("appgvSIG");
123
		v.add("la casa");
124
		v.add("la monta?a");
125
		v.add("la colina");
126
		v.add("las abejas");
127
		v.add("las nutrias");
128
		v.add("las ballenas");
129
		v.add("lasa?a");
130
		v.add("Vector");
131
		v.add("avi?n");
132
		v.add("cami?n");
133
		v.add("autob?s");
134
		
135
		// Show the original vector
136
		System.out.println("Vector original: " + v.toString() + "\n");
137
		
138
		// First kind of sort
139
		stringComparator.setCaseSensitive(true);
140
		List list = v.subList(0, v.size());
141
		Collections.sort(list, stringComparator);
142
		System.out.println("Ordenaci?n normal con case-sensitive:" + list.toString() + "\n");
143
		
144
		// Second kind of sort
145
		stringComparator.setCaseSensitive(false);
146
		list = v.subList(0, v.size());
147
		Collections.sort(list, stringComparator);
148
		System.out.println("Ordenaci?n normal sin case-sensitive:" + list.toString() + "\n");
149
		
150
		
151
		Collator collator = Collator.getInstance(new Locale("es_ES"));
152
		stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
153
		
154
		// Third kind of sort
155
		stringComparator.setCaseSensitive(true);
156
		list = v.subList(0, v.size());
157
		Collections.sort(list, stringComparator);
158
		System.out.println("Ordenaci?n con reglas locales y con case-sensitive:" + list.toString() + "\n");
159

  
160
		// Fourth kind of sort
161
		stringComparator.setCaseSensitive(false);
162
		list = v.subList(0, v.size());
163
		Collections.sort(list, stringComparator);
164
		System.out.println("Ordenaci?n con reglas locales y sin case-sensitive:" + list.toString() + "\n");
165
		
166
		
167
		stringComparator.getLocaleRules().setUseLocaleRules(false);
168
		
169
		// Fifth kind of sort
170
		stringComparator.setCaseSensitive(true);
171
		list = v.subList(0, v.size());
172
		Collections.sort(list, stringComparator);
173
		System.out.println("Ordenaci?n normal con case-sensitive:" + list.toString() + "\n");
174

  
175
		// Sixth kind of sort
176
		stringComparator.setCaseSensitive(false);
177
		list = v.subList(0, v.size());
178
		Collections.sort(list, stringComparator);
179
		System.out.println("Ordenaci?n normal sin case-sensitive:" + list.toString() + "\n");
180
	}	
181
}
0 182

  
tags/v2_0_0_Build_2058/libraries/libIverUtiles/src-test/org/gvsig/utils/vectorUtilities/TestVectorUtilities.java
1
package org.gvsig.utils.vectorUtilities;
2

  
3
import java.text.Collator;
4
import java.util.Locale;
5
import java.util.Vector;
6

  
7
import org.gvsig.utils.StringComparator;
8
import org.gvsig.utils.vectorUtilities.VectorUtilities;
9

  
10

  
11
import junit.framework.TestCase;
12

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

  
54
/**
55
 * Tests the methods of {@link VectorUtilities}
56
 * 
57
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
58
 */
59
public class TestVectorUtilities extends TestCase {
60
	private static String obj;
61
	private static Vector v1 = new Vector();
62
	private static Vector v2 = new Vector();
63
	private static StringComparator stringComparator;
64
	
65
	/*
66
	 *  (non-Javadoc)
67
	 * @see junit.framework.TestCase#setUp()
68
	 */
69
	protected void setUp() throws Exception {
70
		super.setUp();
71
		
72
		// Initialize the StringComparator
73
		stringComparator = new StringComparator();
74

  
75
	    // Set spanish rules and with case sensitive
76
		Collator collator = Collator.getInstance(new Locale("es_ES"));		
77
		stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
78
		stringComparator.setCaseSensitive(false);
79
	}
80

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

  
89
	///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) /////
90

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

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

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

  
tags/v2_0_0_Build_2058/libraries/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_2058/libraries/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));			
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff