Revision 45349

View differences:

tags/org.gvsig.desktop-2.0.297/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestXMLEntity.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: TestXMLEntity.java 30754 2009-09-09 06:42:28Z cordinyana $
27
* $Log$
28
* Revision 1.7  2007-03-05 11:15:43  jaume
29
* *** empty log message ***
30
*
31
* Revision 1.6  2007/03/05 10:03:12  jaume
32
* *** empty log message ***
33
*
34
* Revision 1.5  2007/03/05 09:00:11  jaume
35
* *** empty log message ***
36
*
37
* Revision 1.4  2007/03/02 13:35:56  jaume
38
* *** empty log message ***
39
*
40
* Revision 1.3  2007/03/02 13:27:32  jaume
41
* *** empty log message ***
42
*
43
* Revision 1.2  2007/03/02 13:24:53  jaume
44
* *** empty log message ***
45
*
46
* Revision 1.1  2007/03/02 13:23:50  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1  2006/08/29 06:18:17  jaume
50
* *** empty log message ***
51
*
52
*
53
*/
54
package org.gvsig.utils;
55

  
56
import java.io.File;
57
import java.io.FileReader;
58

  
59
import org.gvsig.tools.junit.AbstractLibraryAutoInitTestCase;
60
import org.gvsig.utils.xmlEntity.generate.XmlTag;
61

  
62

  
63
public class TestXMLEntity extends AbstractLibraryAutoInitTestCase {
64
	private XMLEntity x1, x2, x3, x4;
65
	private XMLEntity gvp1;
66
	private XMLEntity gvp2;
67

  
68
	@Override
69
	protected void doSetUp() throws Exception {
70

  
71
		x1 = new XMLEntity();
72
		x2 = new XMLEntity();
73
		x3 = new XMLEntity();
74

  
75
		
76
		final Object obj1 = new XMLEntity();
77
		final Object obj2 = new XMLEntity();
78
		final Object obj3 = "StringClass";
79

  
80
		
81
		x1.putProperty("boolean1", false);
82
		x1.putProperty("boolean2", true);
83

  
84
		x1.putProperty("integer1", Integer.parseInt("123"));
85
		x1.putProperty("integer2", Integer.parseInt("321"));
86

  
87
		x1.putProperty("long1", Long.parseLong("123123"));
88
		x1.putProperty("long2", Long.parseLong("321321"));
89

  
90
		x1.putProperty("float1", Float.parseFloat("1234.1234"));
91
		x1.putProperty("float2", Float.parseFloat("4321.4321"));
92

  
93
		x1.putProperty("double1", Double.parseDouble("12341234.12341234"));
94
		x1.putProperty("double2", Double.parseDouble("43214321.43214321"));
95

  
96
		x1.putProperty("string1", "String1");
97
		x1.putProperty("string2", "String2");
98

  
99
		x1.putProperty("object1", obj1);
100
		x1.putProperty("object2", obj2);
101

  
102

  
103
		//----- x1 == x2
104
		x2.putProperty("boolean1", false);
105
		x2.putProperty("boolean2", true);
106

  
107
		x2.putProperty("integer1", Integer.parseInt("123"));
108
		x2.putProperty("integer2", Integer.parseInt("321"));
109

  
110
		x2.putProperty("long1", Long.parseLong("123123"));
111
		x2.putProperty("long2", Long.parseLong("321321"));
112

  
113
		x2.putProperty("float1", Float.parseFloat("1234.1234"));
114
		x2.putProperty("float2", Float.parseFloat("4321.4321"));
115

  
116
		x2.putProperty("double1", Double.parseDouble("12341234.12341234"));
117
		x2.putProperty("double2", Double.parseDouble("43214321.43214321"));
118

  
119
		x2.putProperty("string1", "String1");
120
		x2.putProperty("string2", "String2");
121

  
122
		x2.putProperty("object1", obj1);
123
		x2.putProperty("object2", obj2);
124

  
125
		
126
		//----- x1 != x3
127

  
128
		x3.putProperty("boolean1", false);
129
		x3.putProperty("boolean2", true);
130

  
131
		x3.putProperty("integer1", Integer.parseInt("123"));
132
		x3.putProperty("integer2", Integer.parseInt("321"));
133

  
134
		x3.putProperty("long1", Long.parseLong("123123"));
135
		x3.putProperty("long2", Long.parseLong("321321"));
136

  
137
		x3.putProperty("float1", Float.parseFloat("1234.1234"));
138
		x3.putProperty("float2", Float.parseFloat("4321.4321"));
139

  
140
		x3.putProperty("double1", Double.parseDouble("12341234.12341234"));
141
		x3.putProperty("double2", Double.parseDouble("43214321.43214324"));
142

  
143
		x3.putProperty("string1", "String1");
144
		x3.putProperty("string2", "String2");
145

  
146
		x3.putProperty("object1", obj1);
147
		x3.putProperty("object2", obj3);
148
		
149
		
150
		XmlTag tag;
151
		try {
152
			tag = (XmlTag) XmlTag.unmarshal(
153
					new FileReader(new File("testdata/sample.gvp")));
154
			gvp1 = new XMLEntity(tag);
155
			
156
			tag = (XmlTag) XmlTag.unmarshal(
157
					new FileReader(new File("testdata/sample2.gvp")));
158
			gvp2 = new XMLEntity(tag);
159
		} catch (Exception e) {
160
			// TODO Auto-generated catch block
161
			e.printStackTrace();
162
		}
163
		
164
		
165
		 
166
	}
167

  
168
	public void testEquality() {
169
		assertEquals(x1, x2);
170

  
171
		assertFalse(x1.equals(x3));
172
		assertFalse(x2.equals(x3));
173
	}
174

  
175
	
176
	public void testHash() {
177
		final long x1Hash = x1.hash();
178
		final long x2Hash = x2.hash();
179
		final long x3Hash = x3.hash();
180
		
181
		assertTrue("x1 should be equals to x2", x1Hash == x2Hash);
182
		assertTrue("x1 should be distinct to x3", x1Hash != x3Hash);
183
	}
184
	
185
	
186
	public void testSkippedProperties() {
187
		x1.putProperty("skipped1", true, false);
188
		x1.putProperty("skipped2", 1, false);
189
		x1.putProperty("skipped3", 1D, false);
190
		x1.putProperty("skipped4", 1F, false);
191
		x1.putProperty("skipped5", 1L, false);
192
		x1.putProperty("skipped6", "bla bla", false);
193
		
194
		x2.putProperty("skipped1", false, false);
195
		x2.putProperty("skipped2", 2, false);
196
		x2.putProperty("skipped3", 2D, false);
197
		x2.putProperty("skipped4", 2F, false);
198
		x2.putProperty("skipped5", 2L, false);
199
		x2.putProperty("skipped6", "bla bla bleitor", false);
200
		
201
		x3.putProperty("skipped1", false, false);
202
		x3.putProperty("skipped2", 2, false);
203
		x3.putProperty("skipped3", 2D, false);
204
		x3.putProperty("skipped4", 2F, false);
205
		x3.putProperty("skipped5", 2L, false);
206
		x3.putProperty("skipped6", "bla bla bleitor", false);
207

  
208
		
209
		
210
		final long x1Hash = x1.hash();
211
		final long x2Hash = x2.hash();
212
		final long x3Hash = x3.hash();
213
		
214
		assertTrue("x1 should be equals to x2", x1Hash == x2Hash);
215
		assertTrue("x1 should be distinct to x3", x1Hash != x3Hash);
216
		assertTrue("x2 should be distinct to x3", x2Hash != x3Hash);
217
		
218
		x1.remove("skipped1");
219
		x1.remove("skipped2");
220
		x1.remove("skipped3");
221
		x1.remove("skipped4");
222
		x1.remove("skipped5");
223
		x1.remove("skipped6");
224
		
225
		x2.remove("skipped1");
226
		x2.remove("skipped2");
227
		x2.remove("skipped3");
228
		x2.remove("skipped4");
229
		x2.remove("skipped5");
230
		x2.remove("skipped6");
231
		
232
		x3.remove("skipped1");
233
		x3.remove("skipped2");
234
		x3.remove("skipped3");
235
		x3.remove("skipped4");
236
		x3.remove("skipped5");
237
		x3.remove("skipped6");
238
	}
239
	
240
	
241

  
242
	public void testNonSkippedProperties() {
243
		x1.putProperty("non_skipped1", true, true);
244
		x1.putProperty("non_skipped2", 1, true);
245
		x1.putProperty("non_skipped3", 1D, true);
246
		x1.putProperty("non_skipped4", 1F, true);
247
		x1.putProperty("non_skipped5", 1L, true);
248
		x1.putProperty("non_skipped6", "bla bla", true);
249
		
250
		x3.putProperty("non_skipped1", false, true);
251
		x3.putProperty("non_skipped2", 2, true);
252
		x3.putProperty("non_skipped3", 2D, true);
253
		x3.putProperty("non_skipped4", 2F, true);
254
		x3.putProperty("non_skipped5", 2L, true);
255
		x3.putProperty("non_skipped6", "bla bla bleitor", true);
256

  
257
		x2.putProperty("non_skipped1", false, true);
258
		x2.putProperty("non_skipped2", 2, true);
259
		x2.putProperty("non_skipped3", 2D, true);
260
		x2.putProperty("non_skipped4", 2F, true);
261
		x2.putProperty("non_skipped5", 2L, true);
262
		x2.putProperty("non_skipped6", "bla bla bleitor", true);
263
		
264
		final long x1Hash = x1.hash();
265
		final long x2Hash = x2.hash();
266
		final long x3Hash = x3.hash();
267
		
268
		assertFalse("x1 should be distinct to x2", x1Hash == x2Hash);
269
		assertFalse("x1 should be distinct to x3", x1Hash == x3Hash);
270
		assertFalse("x2 should be distinct to x3", x2Hash == x3Hash);
271
		
272
		
273
		// restore the XMEntities to the initial state and ensure that
274
		// passes the tests again
275
		x1.remove("non_skipped1");
276
		x1.remove("non_skipped2");
277
		x1.remove("non_skipped3");
278
		x1.remove("non_skipped4");
279
		x1.remove("non_skipped5");
280
		x1.remove("non_skipped6");
281
		
282
		x2.remove("non_skipped1");
283
		x2.remove("non_skipped2");
284
		x2.remove("non_skipped3");
285
		x2.remove("non_skipped4");
286
		x2.remove("non_skipped5");
287
		x2.remove("non_skipped6");
288
		
289
		x3.remove("non_skipped1");
290
		x3.remove("non_skipped2");
291
		x3.remove("non_skipped3");
292
		x3.remove("non_skipped4");
293
		x3.remove("non_skipped5");
294
		x3.remove("non_skipped6");
295
		
296
		testHash();
297
		testEquality();
298
	}
299
	
300

  
301
	public void testEquivalentProjects() {
302
		final long x1Hash = gvp1.hash();
303
		final long x2Hash = gvp2.hash();
304

  
305
		assertTrue("x1 should be equals to x2", x1Hash == x2Hash);
306
	}
307
	
308
	public void testBenchMark() {
309
		long t_ini, t_unmarshal, t_buildXMLEntity, t_computeHash ;
310
		t_ini = System.currentTimeMillis();
311
		XmlTag tag;
312
		try {
313
			File f= new File("testdata/big.gvp");
314
			tag = (XmlTag) XmlTag.unmarshal(
315
					new FileReader(f));
316
			t_unmarshal = System.currentTimeMillis() - t_ini;
317
			
318
			gvp1 = new XMLEntity(tag);
319
			t_buildXMLEntity = System.currentTimeMillis() - t_unmarshal- t_ini;
320

  
321
			long hash = gvp1.hash();
322
			t_computeHash = System.currentTimeMillis() - t_buildXMLEntity- t_ini;
323
			
324
			assertTrue("BenchMark ("+f.getAbsolutePath()+" "+f.length()/1024+"Kb):" +
325
					"\t-unmarshal time: "+t_unmarshal+" milliseconds\n" +
326
					"\t-build XMLEntity time: "+t_buildXMLEntity+" milliseconds\n" +
327
					"\t-compute hash time: "+t_computeHash+" milliseconds",t_computeHash < 500);
328
			
329
		} catch (Exception e) {
330
			// TODO Auto-generated catch block
331
			e.printStackTrace();
332
		}
333
		
334
	}
335
}
0 336

  
tags/org.gvsig.desktop-2.0.297/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestStringComparator.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils;
25

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

  
32
import org.gvsig.utils.StringComparator;
33

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

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

  
183
		// Fourth kind of sort
184
		stringComparator.setCaseSensitive(false);
185
		list = v.subList(0, v.size());
186
		Collections.sort(list, stringComparator);
187
		System.out.println("Ordenaci?n con reglas locales y sin case-sensitive:" + list.toString() + "\n");
188
		
189
		
190
		stringComparator.getLocaleRules().setUseLocaleRules(false);
191
		
192
		// Fifth kind of sort
193
		stringComparator.setCaseSensitive(true);
194
		list = v.subList(0, v.size());
195
		Collections.sort(list, stringComparator);
196
		System.out.println("Ordenaci?n normal con case-sensitive:" + list.toString() + "\n");
197

  
198
		// Sixth kind of sort
199
		stringComparator.setCaseSensitive(false);
200
		list = v.subList(0, v.size());
201
		Collections.sort(list, stringComparator);
202
		System.out.println("Ordenaci?n normal sin case-sensitive:" + list.toString() + "\n");
203
	}	
204
}
0 205

  
tags/org.gvsig.desktop-2.0.297/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/vectorUtilities/TestVectorUtilities.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils.vectorUtilities;
25

  
26
import java.text.Collator;
27
import java.util.Locale;
28
import java.util.Vector;
29

  
30
import org.gvsig.utils.StringComparator;
31
import org.gvsig.utils.vectorUtilities.VectorUtilities;
32

  
33

  
34
import junit.framework.TestCase;
35

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

  
77
/**
78
 * Tests the methods of {@link VectorUtilities}
79
 * 
80
 * @author Pablo Piqueras Bartolom? (p_queras@hotmail.com)
81
 */
82
public class TestVectorUtilities extends TestCase {
83
	private static String obj;
84
	private static Vector v1 = new Vector();
85
	private static Vector v2 = new Vector();
86
	private static StringComparator stringComparator;
87
	
88
	/*
89
	 *  (non-Javadoc)
90
	 * @see junit.framework.TestCase#setUp()
91
	 */
92
	protected void setUp() throws Exception {
93
		super.setUp();
94
		
95
		// Initialize the StringComparator
96
		stringComparator = new StringComparator();
97

  
98
	    // Set spanish rules and with case sensitive
99
		Collator collator = Collator.getInstance(new Locale("es_ES"));		
100
		stringComparator.setLocaleRules(stringComparator.new LocaleRules(true, collator));
101
		stringComparator.setCaseSensitive(false);
102
	}
103

  
104
	/*
105
	 *  (non-Javadoc)
106
	 * @see junit.framework.TestCase#tearDown()
107
	 */
108
	protected void tearDown() throws Exception {
109
		super.tearDown();
110
	}
111

  
112
	///// TEST OPERATION: addAlphabeticallyOrdered(Vector, Object) /////
113

  
114
	/**
115
	 * A test
116
	 */
117
	public void test1() {
118
		try {
119
			// Insert at the beginning
120
			obj = new String("First");
121
			
122
			VectorUtilities.addAlphabeticallyOrdered(v1, obj);
123
			
124
			System.out.println("Test 1:\nObj: " + obj + "\nResults: " + v1);
125
		} catch (Exception e) {
126
			e.printStackTrace();
127
		}
128
	}
129
	
130
	/**
131
	 * A test
132
	 */
133
	public void test2() {
134
		try {
135
			// Insert at the end
136
			obj = new String("ZZ????");
137
			
138
			VectorUtilities.addAlphabeticallyOrdered(v1, obj);
139
			
140
			System.out.println("Test 2:\nObj: " + obj + "\nResults: " + v1);
141
		} catch (Exception e) {
142
			e.printStackTrace();
143
		}
144
	}
145
	
146
	/**
147
	 * A test
148
	 */
149
	public void test3() {
150
		try {
151
			// An insertion
152
			obj = new String("?and?");
153
			
154
			VectorUtilities.addAlphabeticallyOrdered(v1, obj);
155
			
156
			System.out.println("Test 3:\nObj: " + obj + "\nResults: " + v1);
157
		} catch (Exception e) {
158
			e.printStackTrace();
159
		}
160
	}
161
	
162
	/**
163
	 * A test
164
	 */
165
	public void test4() {
166
		try {
167
			// An insertion
168
			obj = new String("?AND?");
169
			
170
			VectorUtilities.addAlphabeticallyOrdered(v1, obj);
171
			
172
			System.out.println("Test 4:\nObj: " + obj + "\nResults: " + v1);
173
		} catch (Exception e) {
174
			e.printStackTrace();
175
		}
176
	}
177
	
178
	/**
179
	 * A test
180
	 */
181
	public void test5() {
182
		try {
183
			// An insertion
184
			obj = new String("appgvSIG");
185
			
186
			VectorUtilities.addAlphabeticallyOrdered(v1, obj);
187
			
188
			System.out.println("Test 5:\nObj: " + obj + "\nResults: " + v1);
189
		} catch (Exception e) {
190
			e.printStackTrace();
191
		}
192
	}
193
	
194
	/**
195
	 * A test
196
	 */
197
	public void test6() {
198
		try {
199
			// An insertion
200
			obj = new String("libIverUtiles");
201
			
202
			VectorUtilities.addAlphabeticallyOrdered(v1, obj);
203
			
204
			System.out.println("Test 6:\nObj: " + obj + "\nResults: " + v1);
205
		} catch (Exception e) {
206
			e.printStackTrace();
207
		}
208
	}
209

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

  
357
	/**
358
	 * A test
359
	 */
360
	public void test17() {
361
		try {
362
			// An insertion
363
			obj = new String("libUI");
364
			
365
			VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
366
			
367
			System.out.println("Test 17:\nObj: " + obj + "\nResults: " + v2);
368
		} catch (Exception e) {
369
			e.printStackTrace();
370
		}
371
	}
372
	
373
	/**
374
	 * A test
375
	 */
376
	public void test18() {
377
		try {
378
			// An insertion
379
			obj = new String("libIverUtiles");
380
			
381
			VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
382
			
383
			System.out.println("Test 18:\nObj: " + obj + "\nResults: " + v2);
384
		} catch (Exception e) {
385
			e.printStackTrace();
386
		}
387
	}
388
		
389
	/**
390
	 * A test
391
	 */
392
	public void test19() {
393
		try {
394
			// An insertion
395
			obj = new String("extWFS");
396
			
397
			VectorUtilities.addAlphabeticallyOrdered(v2, obj, stringComparator);
398
			
399
			System.out.println("Test 19:\nObj: " + obj + "\nResults: " + v2);
400
		} catch (Exception e) {
401
			e.printStackTrace();
402
		}
403
	}
404
	
405
	///// END TEST OPERATION: addAlphabeticallyOrdered(Vector, Object, Comparator) /////
406
}
0 407

  
tags/org.gvsig.desktop-2.0.297/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/TestStringUtilities.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils;
25

  
26
import org.gvsig.utils.StringUtilities;
27

  
28
import junit.framework.TestCase;
29

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  
tags/org.gvsig.desktop-2.0.297/org.gvsig.desktop.library/org.gvsig.utils/src/test/java/org/gvsig/utils/centerComponent/TestCenterComponent.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.utils.centerComponent;
25

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

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

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

  
42

  
43
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
44
 *
45
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff