Revision 19664 trunk/libraries/libDataSourceBaseDrivers/src-test/org/gvsig/data/datastores/vectorial/driver/DataStoreTest.java
DataStoreTest.java | ||
---|---|---|
166 | 166 |
assertEquals("Iteration error",9,count); |
167 | 167 |
|
168 | 168 |
|
169 |
/// CON EDICION |
|
170 |
|
|
171 |
fs.startEditing(); |
|
172 |
|
|
173 |
IFeature newFeature = fs.createFeature(fs.getDefaultFeatureType()); |
|
174 |
newFeature.set("NOMBRE","BuRjaSOT"); |
|
175 |
newFeature.set("TIPO","MUNICIPIO"); |
|
176 |
fs.insert(newFeature); |
|
177 |
|
|
178 |
|
|
179 |
|
|
169 | 180 |
try { |
181 |
fc = (IFeatureCollection)fs.getDataCollection(); |
|
182 |
} catch (ReadException e1) { |
|
183 |
e1.printStackTrace(); |
|
184 |
fail(); |
|
185 |
} |
|
186 |
|
|
187 |
assertEquals(10, fc.size()); |
|
188 |
|
|
189 |
try { |
|
190 |
fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'",null); |
|
191 |
} catch (ReadException e1) { |
|
192 |
e1.printStackTrace(); |
|
193 |
fail(); |
|
194 |
} |
|
195 |
|
|
196 |
assertEquals(3, fc.size()); |
|
197 |
|
|
198 |
it = fc.iterator(); |
|
199 |
count=0; |
|
200 |
while (it.hasNext()){ |
|
201 |
feature = (IFeature)it.next(); |
|
202 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
|
203 |
count++; |
|
204 |
} |
|
205 |
assertEquals("Iteration error",3,count); |
|
206 |
|
|
207 |
|
|
208 |
try { |
|
209 |
fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE ASC"); |
|
210 |
} catch (ReadException e1) { |
|
211 |
e1.printStackTrace(); |
|
212 |
fail(); |
|
213 |
} |
|
214 |
assertEquals(10, fc.size()); |
|
215 |
it = fc.iterator(); |
|
216 |
count=0; |
|
217 |
pfeature = (IFeature)it.next(); |
|
218 |
count++; |
|
219 |
while (it.hasNext()){ |
|
220 |
feature = (IFeature)it.next(); |
|
221 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
|
222 |
v2 = (Comparable)feature.get("NOMBRE"); |
|
223 |
pfeature=feature; |
|
224 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
|
225 |
count++; |
|
226 |
} |
|
227 |
assertEquals("Iteration error",10,count); |
|
228 |
|
|
229 |
|
|
230 |
try { |
|
231 |
fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE DESC"); |
|
232 |
} catch (ReadException e1) { |
|
233 |
e1.printStackTrace(); |
|
234 |
fail(); |
|
235 |
} |
|
236 |
assertEquals(10, fc.size()); |
|
237 |
it = fc.iterator(); |
|
238 |
|
|
239 |
count=0; |
|
240 |
pfeature = (IFeature)it.next(); |
|
241 |
count++; |
|
242 |
while (it.hasNext()){ |
|
243 |
feature = (IFeature)it.next(); |
|
244 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
|
245 |
v2 = (Comparable)feature.get("NOMBRE"); |
|
246 |
pfeature=feature; |
|
247 |
assertTrue("Short error", (v1.compareTo(v1) >= 0)); |
|
248 |
count++; |
|
249 |
} |
|
250 |
assertEquals("Iteration error",10,count); |
|
251 |
|
|
252 |
|
|
253 |
try { |
|
254 |
fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'","NOMBRE"); |
|
255 |
} catch (ReadException e1) { |
|
256 |
e1.printStackTrace(); |
|
257 |
fail(); |
|
258 |
} |
|
259 |
|
|
260 |
assertEquals(3, fc.size()); |
|
261 |
|
|
262 |
it = fc.iterator(); |
|
263 |
|
|
264 |
count=0; |
|
265 |
pfeature = (IFeature)it.next(); |
|
266 |
assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b")); |
|
267 |
count++; |
|
268 |
while (it.hasNext()){ |
|
269 |
feature = (IFeature)it.next(); |
|
270 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
|
271 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
|
272 |
v2 = (Comparable)feature.get("NOMBRE"); |
|
273 |
pfeature=feature; |
|
274 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
|
275 |
count++; |
|
276 |
} |
|
277 |
assertEquals("Iteration error",3,count); |
|
278 |
|
|
279 |
|
|
280 |
|
|
281 |
try { |
|
282 |
fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(NOMBRE) Desc"); |
|
283 |
} catch (ReadException e1) { |
|
284 |
e1.printStackTrace(); |
|
285 |
fail(); |
|
286 |
} |
|
287 |
assertEquals(10, fc.size()); |
|
288 |
it = fc.iterator(); |
|
289 |
count=0; |
|
290 |
pfeature = (IFeature)it.next(); |
|
291 |
System.out.println(pfeature.getString("NOMBRE")); |
|
292 |
count++; |
|
293 |
while (it.hasNext()){ |
|
294 |
feature = (IFeature)it.next(); |
|
295 |
v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase(); |
|
296 |
v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase(); |
|
297 |
pfeature=feature; |
|
298 |
assertTrue("Short error", (v1.compareTo(v2) >= 0)); |
|
299 |
System.out.println(pfeature.getString("NOMBRE")); |
|
300 |
count++; |
|
301 |
} |
|
302 |
assertEquals("Iteration error",10,count); |
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
|
|
307 |
|
|
308 |
|
|
309 |
|
|
310 |
fs.cancelEditing(); |
|
311 |
|
|
312 |
|
|
313 |
try { |
|
170 | 314 |
fs.close(); |
171 | 315 |
} catch (CloseException e) { |
172 | 316 |
e.printStackTrace(); |
... | ... | |
331 | 475 |
} |
332 | 476 |
assertEquals("Iteration error",9,count); |
333 | 477 |
|
478 |
|
|
479 |
|
|
480 |
/// CON EDICION |
|
481 |
|
|
482 |
fs.startEditing(); |
|
483 |
|
|
484 |
IFeature newFeature = fs.createFeature(fs.getDefaultFeatureType()); |
|
485 |
newFeature.set("NOMBRE","BuRjaSOT"); |
|
486 |
newFeature.set("TIPO","MUNICIPIO"); |
|
487 |
fs.insert(newFeature); |
|
488 |
|
|
489 |
|
|
490 |
|
|
334 | 491 |
try { |
492 |
fc = (IFeatureCollection)fs.getDataCollection(); |
|
493 |
} catch (ReadException e1) { |
|
494 |
e1.printStackTrace(); |
|
495 |
fail(); |
|
496 |
} |
|
497 |
|
|
498 |
assertEquals(10, fc.size()); |
|
499 |
|
|
500 |
try { |
|
501 |
fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'",null); |
|
502 |
} catch (ReadException e1) { |
|
503 |
e1.printStackTrace(); |
|
504 |
fail(); |
|
505 |
} |
|
506 |
|
|
507 |
assertEquals(3, fc.size()); |
|
508 |
|
|
509 |
it = fc.iterator(); |
|
510 |
count=0; |
|
511 |
while (it.hasNext()){ |
|
512 |
feature = (IFeature)it.next(); |
|
513 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
|
514 |
count++; |
|
515 |
} |
|
516 |
assertEquals("Iteration error",3,count); |
|
517 |
|
|
518 |
|
|
519 |
try { |
|
520 |
fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE ASC"); |
|
521 |
} catch (ReadException e1) { |
|
522 |
e1.printStackTrace(); |
|
523 |
fail(); |
|
524 |
} |
|
525 |
assertEquals(10, fc.size()); |
|
526 |
it = fc.iterator(); |
|
527 |
count=0; |
|
528 |
pfeature = (IFeature)it.next(); |
|
529 |
count++; |
|
530 |
while (it.hasNext()){ |
|
531 |
feature = (IFeature)it.next(); |
|
532 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
|
533 |
v2 = (Comparable)feature.get("NOMBRE"); |
|
534 |
pfeature=feature; |
|
535 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
|
536 |
count++; |
|
537 |
} |
|
538 |
assertEquals("Iteration error",10,count); |
|
539 |
|
|
540 |
|
|
541 |
try { |
|
542 |
fc = (IFeatureCollection)fs.getDataCollection(null,null,"NOMBRE DESC"); |
|
543 |
} catch (ReadException e1) { |
|
544 |
e1.printStackTrace(); |
|
545 |
fail(); |
|
546 |
} |
|
547 |
assertEquals(10, fc.size()); |
|
548 |
it = fc.iterator(); |
|
549 |
|
|
550 |
count=0; |
|
551 |
pfeature = (IFeature)it.next(); |
|
552 |
count++; |
|
553 |
while (it.hasNext()){ |
|
554 |
feature = (IFeature)it.next(); |
|
555 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
|
556 |
v2 = (Comparable)feature.get("NOMBRE"); |
|
557 |
pfeature=feature; |
|
558 |
assertTrue("Short error", (v1.compareTo(v1) >= 0)); |
|
559 |
count++; |
|
560 |
} |
|
561 |
assertEquals("Iteration error",10,count); |
|
562 |
|
|
563 |
|
|
564 |
try { |
|
565 |
fc = (IFeatureCollection)fs.getDataCollection(null,"lower(NOMBRE) like 'b%'","NOMBRE"); |
|
566 |
} catch (ReadException e1) { |
|
567 |
e1.printStackTrace(); |
|
568 |
fail(); |
|
569 |
} |
|
570 |
|
|
571 |
assertEquals(3, fc.size()); |
|
572 |
|
|
573 |
it = fc.iterator(); |
|
574 |
|
|
575 |
count=0; |
|
576 |
pfeature = (IFeature)it.next(); |
|
577 |
assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b")); |
|
578 |
count++; |
|
579 |
while (it.hasNext()){ |
|
580 |
feature = (IFeature)it.next(); |
|
581 |
assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b")); |
|
582 |
v1 = (Comparable)pfeature.get("NOMBRE"); |
|
583 |
v2 = (Comparable)feature.get("NOMBRE"); |
|
584 |
pfeature=feature; |
|
585 |
assertTrue("Short error", (v1.compareTo(v1) <= 0)); |
|
586 |
count++; |
|
587 |
} |
|
588 |
assertEquals("Iteration error",3,count); |
|
589 |
|
|
590 |
|
|
591 |
|
|
592 |
try { |
|
593 |
fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(NOMBRE) Desc"); |
|
594 |
} catch (ReadException e1) { |
|
595 |
e1.printStackTrace(); |
|
596 |
fail(); |
|
597 |
} |
|
598 |
assertEquals(10, fc.size()); |
|
599 |
it = fc.iterator(); |
|
600 |
count=0; |
|
601 |
pfeature = (IFeature)it.next(); |
|
602 |
System.out.println(pfeature.getString("NOMBRE")); |
|
603 |
count++; |
|
604 |
while (it.hasNext()){ |
|
605 |
feature = (IFeature)it.next(); |
|
606 |
v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase(); |
|
607 |
v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase(); |
|
608 |
pfeature=feature; |
|
609 |
assertTrue("Short error", (v1.compareTo(v2) >= 0)); |
|
610 |
System.out.println(pfeature.getString("NOMBRE")); |
|
611 |
count++; |
|
612 |
} |
|
613 |
assertEquals("Iteration error",10,count); |
|
614 |
|
|
615 |
|
|
616 |
|
|
617 |
|
|
618 |
fs.cancelEditing(); |
|
619 |
|
|
620 |
|
|
621 |
|
|
622 |
try { |
|
335 | 623 |
fs.close(); |
336 | 624 |
} catch (CloseException e) { |
337 | 625 |
e.printStackTrace(); |
Also available in: Unified diff