Statistics
| Revision:

svn-gvsig-desktop / branches / Mobile_Compatible_Hito_1 / libFMap_dataFile / src-test / org / gvsig / data / datastores / vectorial / file / DataStoreTest.java @ 22125

History | View | Annotate | Download (36.3 KB)

1
package org.gvsig.data.datastores.vectorial.file;
2

    
3
import java.io.File;
4
import java.util.Iterator;
5

    
6
import junit.framework.TestCase;
7

    
8
import org.gvsig.data.CloseException;
9
import org.gvsig.data.DataCollection;
10
import org.gvsig.data.DataManager;
11
import org.gvsig.data.DataStoreParameters;
12
import org.gvsig.data.InitializeException;
13
import org.gvsig.data.ReadException;
14
import org.gvsig.data.Resource;
15
import org.gvsig.data.ResourceManager;
16
import org.gvsig.data.WriteException;
17
import org.gvsig.data.vectorial.AbstractFeatureStore;
18
import org.gvsig.util.observer.Observer;
19

    
20
public class DataStoreTest extends TestCase {
21

    
22
        private File dbffile = new File(DataStoreTest.class.getResource("data/prueba.dbf").getFile());
23
        private File shpfile = new File(DataStoreTest.class.getResource("data/prueba.shp").getFile());
24
        private File dxffile = new File(DataStoreTest.class.getResource("data/prueba.dxf").getFile());
25
        private File dgnfile = new File(DataStoreTest.class.getResource("data/prueba.dgn").getFile());
26

    
27
        public static void main(String[] args) {
28
                junit.textui.TestRunner.run(DataStoreTest.class);
29
        }
30

    
31
        protected void setUp() throws Exception {
32
                super.setUp();
33

    
34
        }
35

    
36
        public void testDBF() {
37
//                try {
38
//                        System.out.println("======= DBF ==============");
39
//                        org.gvsig.data.datastores.vectorial.file.dbf.Register.selfRegister();
40
//
41
//                        DataManager dsm=DataManager.getManager();
42
//
43
//
44
//                        DataStoreParameters dp=dsm.createDataStoreParameters(DBFStore.DATASTORE_NAME);
45
//                        ((DBFStoreParameters)dp).setFile(dbffile);
46
//
47
//                        driverTest(dp,null,null,true);
48
//                        FeatureStore fs=null;
49
//                        try {
50
//                                fs = (FeatureStore)dsm.createDataStore(dp);
51
//                        } catch (InitializeException e) {
52
//                                e.printStackTrace();
53
//                                fail("Exception:" + e);
54
//                        }
55
//                        assertNotNull("Can't create Feature Store", fs);
56
//
57
//
58
//                        fs.open();
59
//
60
//
61
//                        Iterator it;
62
//                        FeatureCollection fc;
63
//                        Comparable v1,v2;
64
//                        Feature feature,pfeature;
65
//                        long count;
66
//
67
//
68
//                        fc = (FeatureCollection)fs.getDataCollection();
69
//
70
//                        assertEquals(9, fc.size());
71
//
72
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'",null);
73
//
74
//                        assertEquals(2, fc.size());
75
//
76
//                        it = fc.iterator();
77
//                        count=0;
78
//                        while (it.hasNext()){
79
//                                feature = (Feature)it.next();
80
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
81
//                                count++;
82
//                        }
83
//                        assertEquals("Iteration error",2,count);
84
//
85
//
86
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE ASC");
87
//                        assertEquals(9, fc.size());
88
//                        it = fc.iterator();
89
//                        count=0;
90
//                        pfeature = (Feature)it.next();
91
//                        count++;
92
//                        while (it.hasNext()){
93
//                                feature = (Feature)it.next();
94
//                                v1 = (Comparable)pfeature.get("NOMBRE");
95
//                                v2 = (Comparable)feature.get("NOMBRE");
96
//                                pfeature=feature;
97
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
98
//                                count++;
99
//                        }
100
//                        assertEquals("Iteration error",9,count);
101
//
102
//
103
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE DESC");
104
//                        assertEquals(9, fc.size());
105
//                        it = fc.iterator();
106
//
107
//                        count=0;
108
//                        pfeature = (Feature)it.next();
109
//                        count++;
110
//                        while (it.hasNext()){
111
//                                feature = (Feature)it.next();
112
//                                v1 = (Comparable)pfeature.get("NOMBRE");
113
//                                v2 = (Comparable)feature.get("NOMBRE");
114
//                                pfeature=feature;
115
//                                assertTrue("Short error", (v1.compareTo(v1) >= 0));
116
//                                count++;
117
//                        }
118
//                        assertEquals("Iteration error",9,count);
119
//
120
//
121
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'","NOMBRE");
122
//
123
//                        assertEquals(2, fc.size());
124
//
125
//                        it = fc.iterator();
126
//
127
//                        count=0;
128
//                        pfeature = (Feature)it.next();
129
//                        assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
130
//                        count++;
131
//                        while (it.hasNext()){
132
//                                feature = (Feature)it.next();
133
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
134
//                                v1 = (Comparable)pfeature.get("NOMBRE");
135
//                                v2 = (Comparable)feature.get("NOMBRE");
136
//                                pfeature=feature;
137
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
138
//                                count++;
139
//                        }
140
//                        assertEquals("Iteration error",2,count);
141
//
142
//
143
//
144
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Tipo,lower(NOMBRE) Desc");
145
//                        assertEquals(9, fc.size());
146
//                        it = fc.iterator();
147
//                        count=0;
148
//                        pfeature = (Feature)it.next();
149
//                        System.out.println(pfeature.getString("NOMBRE"));
150
//                        count++;
151
//                        while (it.hasNext()){
152
//                                feature = (Feature)it.next();
153
//                                v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
154
//                                v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
155
//                                pfeature=feature;
156
//                                assertTrue("Short error", (v1.compareTo(v2) >= 0));
157
//                                System.out.println(pfeature.getString("NOMBRE"));
158
//                                count++;
159
//                        }
160
//                        assertEquals("Iteration error",9,count);
161
//
162
//
163
//                        /// CON  EDICION
164
//
165
//                        fs.startEditing();
166
//
167
//                        Feature newFeature = fs.createDefaultFeature(true);
168
//                        newFeature.editing();
169
//                        newFeature.set("NOMBRE","BuRjaSOT");
170
//                        newFeature.set("TIPO","MUNICIPIO");
171
//                        fs.insert(newFeature);
172
//
173
//                        try {
174
//                                fc = (FeatureCollection)fs.getDataCollection();
175
//                        } catch (ReadException e1) {
176
//                                e1.printStackTrace();
177
//                                fail();
178
//                        }
179
//
180
//                        assertEquals(10, fc.size());
181
//
182
//                        try {
183
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'",null);
184
//                        } catch (ReadException e1) {
185
//                                e1.printStackTrace();
186
//                                fail();
187
//                        }
188
//
189
//                        assertEquals(3, fc.size());
190
//
191
//                        it = fc.iterator();
192
//                        count=0;
193
//                        while (it.hasNext()){
194
//                                feature = (Feature)it.next();
195
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
196
//                                count++;
197
//                        }
198
//                        assertEquals("Iteration error",3,count);
199
//
200
//
201
//                        try {
202
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE ASC");
203
//                        } catch (ReadException e1) {
204
//                                e1.printStackTrace();
205
//                                fail();
206
//                        }
207
//                        assertEquals(10, fc.size());
208
//                        it = fc.iterator();
209
//                        count=0;
210
//                        pfeature = (Feature)it.next();
211
//                        count++;
212
//                        while (it.hasNext()){
213
//                                feature = (Feature)it.next();
214
//                                v1 = (Comparable)pfeature.get("NOMBRE");
215
//                                v2 = (Comparable)feature.get("NOMBRE");
216
//                                pfeature=feature;
217
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
218
//                                count++;
219
//                        }
220
//                        assertEquals("Iteration error",10,count);
221
//
222
//
223
//                        try {
224
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE DESC");
225
//                        } catch (ReadException e1) {
226
//                                e1.printStackTrace();
227
//                                fail();
228
//                        }
229
//                        assertEquals(10, fc.size());
230
//                        it = fc.iterator();
231
//
232
//                        count=0;
233
//                        pfeature = (Feature)it.next();
234
//                        count++;
235
//                        while (it.hasNext()){
236
//                                feature = (Feature)it.next();
237
//                                v1 = (Comparable)pfeature.get("NOMBRE");
238
//                                v2 = (Comparable)feature.get("NOMBRE");
239
//                                pfeature=feature;
240
//                                if (v1!=null && v2!=null)
241
//                                        assertTrue("Short error", (v1.compareTo(v1) >= 0));
242
//                                count++;
243
//                        }
244
//                        assertEquals("Iteration error",10,count);
245
//
246
//
247
//                        try {
248
//                                fc = (FeatureCollection)fs.getDataCollection(new String[]{"NOMBRE"},"lower(NOMBRE) like 'b%'","NOMBRE");
249
//                        } catch (ReadException e1) {
250
//                                e1.printStackTrace();
251
//                                fail();
252
//                        }
253
//
254
//                        assertEquals(3, fc.size());
255
//
256
//                        it = fc.iterator();
257
//
258
//                        count=0;
259
//                        pfeature = (Feature)it.next();
260
//                        assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
261
//                        count++;
262
//                        while (it.hasNext()){
263
//                                feature = (Feature)it.next();
264
//                                if (!(feature instanceof MemoryFeature)){ //FIXME OJO con los featureType de los Feature en memoria
265
//                                        assertEquals(1, feature.getType().size());
266
//                                }
267
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
268
//                                v1 = (Comparable)pfeature.get("NOMBRE");
269
//                                v2 = (Comparable)feature.get("NOMBRE");
270
//                                pfeature=feature;
271
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
272
//                                count++;
273
//                        }
274
//                        assertEquals("Iteration error",3,count);
275
//
276
//
277
//
278
//                        try {
279
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Tipo,lower(NOMBRE) Desc");
280
//                        } catch (ReadException e1) {
281
//                                e1.printStackTrace();
282
//                                fail();
283
//                        }
284
//                        assertEquals(10, fc.size());
285
//                        it = fc.iterator();
286
//                        count=0;
287
//                        pfeature = (Feature)it.next();
288
//                        System.out.println(pfeature.getString("TIPO")+","+pfeature.getString("NOMBRE"));
289
//                        count++;
290
//                        while (it.hasNext()){
291
//                                feature = (Feature)it.next();
292
//                                System.out.println(feature.getString("TIPO")+","+feature.getString("NOMBRE"));
293
//                                v1 = (Comparable)((String)pfeature.get("TIPO")).toLowerCase();
294
//                                v2 = (Comparable)((String)feature.get("TIPO")).toLowerCase();
295
//                                assertTrue("Short error", (v2.compareTo(v1) >= 0));
296
//                                if (v1.compareTo(v2) == 0){
297
//                                        v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
298
//                                        v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
299
//                                        assertTrue("Short error", (v1.compareTo(v2) >= 0));
300
//                                }
301
//                                pfeature=feature;
302
//
303
////                                System.out.println(pfeature.getString("TIPO")+","+pfeature.getString("NOMBRE"));
304
//                                count++;
305
//                        }
306
//                        assertEquals("Iteration error",10,count);
307
//
308
//                        fs.cancelEditing();
309
//
310
//                        try {
311
//                                fs.close();
312
//                        } catch (CloseException e) {
313
//                                e.printStackTrace();
314
//                                fail("Exception:" + e);
315
//                        }
316
//
317
//
318
//                        System.out.println("======= /DBF ==============");
319
//
320
//                } catch (DataException e) {
321
//                        // TODO Auto-generated catch block
322
//                        e.printStackTrace();
323
//                }
324
        }
325

    
326
        public void testSHP() {
327
//                try {
328
//                        System.out.println("======= SHP ==============");
329
//                        org.gvsig.data.datastores.vectorial.file.shp.Register.selfRegister();
330
//                        org.gvsig.data.datastores.vectorial.file.dbf.Register.selfRegister();
331
//
332
//                        DataManager dsm=DataManager.getManager();
333
//
334
//
335
//                        DataStoreParameters dp=dsm.createDataStoreParameters(SHPStore.DATASTORE_NAME);
336
//                        ((SHPStoreParameters)dp).setFile(shpfile);
337
////                        ((SHPStoreParameters)dp).setSHXFile(SHP.getShxFile(shpfile));
338
////                        ((SHPStoreParameters)dp).setDBFFile(SHP.getDbfFile(shpfile));
339
//
340
//
341
//                        driverTest(dp,null,null,true);
342
//
343
//                        FeatureStore fs=null;
344
//                        try {
345
//                                fs = (FeatureStore)dsm.createDataStore(dp);
346
//                        } catch (InitializeException e) {
347
//                                e.printStackTrace();
348
//                                fail("Exception:" + e);
349
//                        }
350
//
351
//                        assertNotNull("Can't create Feature Store", fs);
352
//
353
//
354
//                        fs.open();
355
//
356
//
357
//                        Iterator it;
358
//                        FeatureCollection fc;
359
//                        Comparable v1,v2;
360
//                        Feature feature,pfeature;
361
//                        long count;
362
//
363
//
364
//                        fc = (FeatureCollection)fs.getDataCollection();
365
//
366
//                        assertEquals(9, fc.size());
367
//
368
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'",null);
369
//
370
//                        assertEquals(2, fc.size());
371
//
372
//                        it = fc.iterator();
373
//                        count=0;
374
//                        while (it.hasNext()){
375
//                                feature = (Feature)it.next();
376
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
377
//                                count++;
378
//                        }
379
//                        assertEquals("Iteration error",2,count);
380
//
381
//
382
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE");
383
//                        assertEquals(9, fc.size());
384
//                        it = fc.iterator();
385
//                        count=0;
386
//                        pfeature = (Feature)it.next();
387
//                        count++;
388
//                        while (it.hasNext()){
389
//                                feature = (Feature)it.next();
390
//                                v1 = (Comparable)pfeature.get("NOMBRE");
391
//                                v2 = (Comparable)feature.get("NOMBRE");
392
//                                pfeature=feature;
393
//                                assertTrue("Short error", (v1.compareTo(v2) <= 0));
394
//                                count++;
395
//                        }
396
//                        assertEquals("Iteration error",9,count);
397
//
398
//
399
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE DESC");
400
//                        assertEquals(9, fc.size());
401
//                        it = fc.iterator();
402
//                        count=0;
403
//                        pfeature = (Feature)it.next();
404
//                        System.out.println(pfeature.getString("NOMBRE"));
405
//                        count++;
406
//                        while (it.hasNext()){
407
//                                feature = (Feature)it.next();
408
//                                v1 = (Comparable)pfeature.get("NOMBRE");
409
//                                v2 = (Comparable)feature.get("NOMBRE");
410
//                                pfeature=feature;
411
//                                assertTrue("Short error", (v1.compareTo(v2) >= 0));
412
//                                System.out.println(pfeature.getString("NOMBRE"));
413
//                                count++;
414
//                        }
415
//                        assertEquals("Iteration error",9,count);
416
//
417
//
418
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'","NOMBRE ASC");
419
//
420
//                        assertEquals(2, fc.size());
421
//
422
//                        it = fc.iterator();
423
//
424
//                        count=0;
425
//                        pfeature = (Feature)it.next();
426
//                        assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
427
//                        count++;
428
//                        while (it.hasNext()){
429
//                                feature = (Feature)it.next();
430
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
431
//                                v1 = (Comparable)pfeature.get("NOMBRE");
432
//                                v2 = (Comparable)feature.get("NOMBRE");
433
//                                pfeature=feature;
434
//                                assertTrue("Short error", (v1.compareTo(v2) <= 0));
435
//                                count++;
436
//                        }
437
//                        assertEquals("Iteration error",2,count);
438
//
439
//
440
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"lower(NOMBRE) ASC");
441
//                        assertEquals(9, fc.size());
442
//                        it = fc.iterator();
443
//                        count=0;
444
//                        pfeature = (Feature)it.next();
445
//                        count++;
446
//                        while (it.hasNext()){
447
//                                feature = (Feature)it.next();
448
//                                v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
449
//                                v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
450
//                                pfeature=feature;
451
//                                assertTrue("Short error", (v1.compareTo(v2) <= 0));
452
//                                count++;
453
//                        }
454
//                        assertEquals("Iteration error",9,count);
455
//
456
//
457
//
458
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Tipo,lower(NOMBRE) Desc");
459
//                        assertEquals(9, fc.size());
460
//                        it = fc.iterator();
461
//                        count=0;
462
//                        pfeature = (Feature)it.next();
463
//                        System.out.println(pfeature.getString("NOMBRE"));
464
//                        count++;
465
//                        while (it.hasNext()){
466
//                                feature = (Feature)it.next();
467
//                                v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
468
//                                v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
469
//                                pfeature=feature;
470
//                                assertTrue("Short error", (v1.compareTo(v2) >= 0));
471
//                                System.out.println(pfeature.getString("NOMBRE"));
472
//                                count++;
473
//                        }
474
//                        assertEquals("Iteration error",9,count);
475
//
476
//
477
//
478
//                        /// CON  EDICION
479
//
480
//                        fs.startEditing();
481
//
482
//                        Feature newFeature = fs.createDefaultFeature(true);
483
//                        newFeature.editing();
484
//                        newFeature.set("NOMBRE","BuRjaSOT");
485
//                        newFeature.set("TIPO","MUNICIPIO");
486
//                        fs.insert(newFeature);
487
//
488
//
489
//
490
//                        try {
491
//                                fc = (FeatureCollection)fs.getDataCollection();
492
//                        } catch (ReadException e1) {
493
//                                e1.printStackTrace();
494
//                                fail();
495
//                        }
496
//
497
//                        assertEquals(10, fc.size());
498
//
499
//                        try {
500
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'",null);
501
//                        } catch (ReadException e1) {
502
//                                e1.printStackTrace();
503
//                                fail();
504
//                        }
505
//
506
//                        assertEquals(3, fc.size());
507
//
508
//                        it = fc.iterator();
509
//                        count=0;
510
//                        while (it.hasNext()){
511
//                                feature = (Feature)it.next();
512
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
513
//                                count++;
514
//                        }
515
//                        assertEquals("Iteration error",3,count);
516
//
517
//
518
//                        try {
519
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE ASC");
520
//                        } catch (ReadException e1) {
521
//                                e1.printStackTrace();
522
//                                fail();
523
//                        }
524
//                        assertEquals(10, fc.size());
525
//                        it = fc.iterator();
526
//                        count=0;
527
//                        pfeature = (Feature)it.next();
528
//                        count++;
529
//                        while (it.hasNext()){
530
//                                feature = (Feature)it.next();
531
//                                v1 = (Comparable)pfeature.get("NOMBRE");
532
//                                v2 = (Comparable)feature.get("NOMBRE");
533
//                                pfeature=feature;
534
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
535
//                                count++;
536
//                        }
537
//                        assertEquals("Iteration error",10,count);
538
//
539
//
540
//                        try {
541
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"NOMBRE DESC");
542
//                        } catch (ReadException e1) {
543
//                                e1.printStackTrace();
544
//                                fail();
545
//                        }
546
//                        assertEquals(10, fc.size());
547
//                        it = fc.iterator();
548
//
549
//                        count=0;
550
//                        pfeature = (Feature)it.next();
551
//                        count++;
552
//                        while (it.hasNext()){
553
//                                feature = (Feature)it.next();
554
//                                v1 = (Comparable)pfeature.get("NOMBRE");
555
//                                v2 = (Comparable)feature.get("NOMBRE");
556
//                                pfeature=feature;
557
//                                assertTrue("Short error", (v1.compareTo(v1) >= 0));
558
//                                count++;
559
//                        }
560
//                        assertEquals("Iteration error",10,count);
561
//
562
//
563
//                        try {
564
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"lower(NOMBRE) like 'b%'","NOMBRE");
565
//                        } catch (ReadException e1) {
566
//                                e1.printStackTrace();
567
//                                fail();
568
//                        }
569
//
570
//                        assertEquals(3, fc.size());
571
//
572
//                        it = fc.iterator();
573
//
574
//                        count=0;
575
//                        pfeature = (Feature)it.next();
576
//                        assertTrue(pfeature.getString("NOMBRE").toLowerCase().startsWith("b"));
577
//                        count++;
578
//                        while (it.hasNext()){
579
//                                feature = (Feature)it.next();
580
//                                assertTrue("Filter error",feature.getString("NOMBRE").toLowerCase().startsWith("b"));
581
//                                v1 = (Comparable)pfeature.get("NOMBRE");
582
//                                v2 = (Comparable)feature.get("NOMBRE");
583
//                                pfeature=feature;
584
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
585
//                                count++;
586
//                        }
587
//                        assertEquals("Iteration error",3,count);
588
//
589
//
590
//
591
//                        try {
592
//                                fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Tipo,lower(NOMBRE) Desc");
593
//                        } catch (ReadException e1) {
594
//                                e1.printStackTrace();
595
//                                fail();
596
//                        }
597
//                        assertEquals(10, fc.size());
598
//                        it = fc.iterator();
599
//                        count=0;
600
//                        pfeature = (Feature)it.next();
601
//                        System.out.println(pfeature.getString("NOMBRE"));
602
//                        count++;
603
//                        while (it.hasNext()){
604
//                                feature = (Feature)it.next();
605
//                                v1 = (Comparable)((String)pfeature.get("NOMBRE")).toLowerCase();
606
//                                v2 = (Comparable)((String)feature.get("NOMBRE")).toLowerCase();
607
//                                pfeature=feature;
608
//                                assertTrue("Short error", (v1.compareTo(v2) >= 0));
609
//                                System.out.println(pfeature.getString("NOMBRE"));
610
//                                count++;
611
//                        }
612
//                        assertEquals("Iteration error",10,count);
613
//
614
//
615
//
616
//
617
//                        fs.cancelEditing();
618
//
619
//
620
//
621
//                        try {
622
//                                fs.close();
623
//                        } catch (CloseException e) {
624
//                                e.printStackTrace();
625
//                                fail("Exception:" + e);
626
//                        }
627
//
628
//
629
//
630
//                        System.out.println("======= /SHP ==============");
631
//                } catch (DataException e) {
632
//                        // TODO Auto-generated catch block
633
//                        e.printStackTrace();
634
//                }
635
        }
636

    
637
        public void testDXF() {
638
//                try {
639
//                        System.out.println("======= DXF ==============");
640
//                        org.gvsig.data.datastores.vectorial.file.dxf.Register.selfRegister();
641
//
642
//                        DataManager dsm=DataManager.getManager();
643
//
644
//
645
//                        DataStoreParameters dp=dsm.createDataStoreParameters(DXFStore.DATASTORE_NAME);
646
//                        ((DXFStoreParameters)dp).setFile(dxffile);
647
//                        IProjection proj = CRSFactory.getCRS("EPSG:23030");
648
//                        ((DXFStoreParameters)dp).setProjection(proj);
649
//                        driverTest(dp,null,null,true);
650
//
651
//                        FeatureStore fs=null;
652
//                        try {
653
//                                fs = (FeatureStore)dsm.createDataStore(dp);
654
//                        } catch (InitializeException e) {
655
//                                e.printStackTrace();
656
//                                fail("Exception:" + e);
657
//                        }
658
//                        assertNotNull("Can't create Feature Store", fs);
659
//
660
//
661
//                        fs.open();
662
//
663
//
664
//                        Iterator it;
665
//                        FeatureCollection fc;
666
//                        Comparable v1,v2;
667
//                        Feature feature,pfeature;
668
//                        long count;
669
//
670
//
671
//                        fc = (FeatureCollection)fs.getDataCollection();
672
//
673
//                        assertEquals(10, fc.size());
674
//
675
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"Color > '7'",null);
676
//
677
//                        assertEquals(2, fc.size());
678
//
679
//                        it = fc.iterator();
680
//                        count=0;
681
//                        while (it.hasNext()){
682
//                                feature = (Feature)it.next();
683
//                                assertTrue("Filter error",feature.getInt("Color")>7);
684
//                                count++;
685
//                        }
686
//                        assertEquals("Iteration error",2,count);
687
//
688
//
689
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Layer ASC");
690
//                        assertEquals(10, fc.size());
691
//                        it = fc.iterator();
692
//                        count=0;
693
//                        pfeature = (Feature)it.next();
694
//                        count++;
695
//                        while (it.hasNext()){
696
//                                feature = (Feature)it.next();
697
//                                v1 = (Comparable)pfeature.get("Layer");
698
//                                v2 = (Comparable)feature.get("Layer");
699
//                                pfeature=feature;
700
//                                assertTrue("Short error", (v1.compareTo(v1) <= 0));
701
//                                count++;
702
//                        }
703
//                        assertEquals("Iteration error",10,count);
704
//
705
//
706
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Layer DESC");
707
//                        assertEquals(10, fc.size());
708
//                        it = fc.iterator();
709
//
710
//                        count=0;
711
//                        pfeature = (Feature)it.next();
712
//                        count++;
713
//                        while (it.hasNext()){
714
//                                feature = (Feature)it.next();
715
//                                v1 = (Comparable)pfeature.get("Layer");
716
//                                v2 = (Comparable)feature.get("Layer");
717
//                                pfeature=feature;
718
//                                assertTrue("Short error", (v1.compareTo(v1) >= 0));
719
//                                count++;
720
//                        }
721
//                        assertEquals("Iteration error",10,count);
722
//
723
//
724
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"Color > '7'","Layer ASC");
725
//
726
//                        assertEquals(2, fc.size());
727
//
728
//                        it = fc.iterator();
729
//
730
//                        count=0;
731
//                        pfeature = (Feature)it.next();
732
//                        assertTrue(pfeature.getInt("Color")>7);
733
//                        count++;
734
//                        while (it.hasNext()){
735
//                                feature = (Feature)it.next();
736
//                                assertTrue("Filter error",feature.getInt("Color")>7);
737
//                                v1 = (Comparable)pfeature.get("Color");
738
//                                v2 = (Comparable)feature.get("Color");
739
//                                pfeature=feature;
740
//                                Integer i1=(Integer)v1;
741
//                                Integer i2=(Integer)v2;
742
//                                assertTrue("Short error", (i1.intValue()>i2.intValue()));
743
//                                count++;
744
//                        }
745
//                        assertEquals("Iteration error",2,count);
746
//
747
//
748
//
749
////                        fc = (FeatureCollection)fs.getDataCollection(null,null,"Color,Layer Desc");
750
////                        assertEquals(10, fc.size());
751
////                        it = fc.iterator();
752
////                        count=0;
753
////                        pfeature = (Feature)it.next();
754
////                        System.out.println(pfeature.getString("Layer"));
755
////                        count++;
756
////                        while (it.hasNext()){
757
////                        feature = (Feature)it.next();
758
////                        v1 = (Comparable)((String)pfeature.get("Layer")).toLowerCase();
759
////                        v2 = (Comparable)((String)feature.get("Layer")).toLowerCase();
760
////                        pfeature=feature;
761
////                        assertTrue("Short error", (v1.compareTo(v2) >= 0));
762
////                        System.out.println(pfeature.getString("Layer"));
763
////                        count++;
764
////                        }
765
////                        assertEquals("Iteration error",10,count);
766
//
767
//
768
//                        try {
769
//                                fs.close();
770
//                        } catch (CloseException e) {
771
//                                e.printStackTrace();
772
//                                fail("Exception:" + e);
773
//                        }
774
//
775
//
776
//                        System.out.println("======= /DXF ==============");
777
//                } catch (OpenException e1) {
778
//                        e1.printStackTrace();
779
//                        fail();
780
//                } catch (ReadException e) {
781
//                        // TODO Auto-generated catch block
782
//                        e.printStackTrace();
783
//                }
784
        }
785

    
786
        public void testDGN() {
787
//                try {
788
//                        System.out.println("======= DGN ==============");
789
//                        org.gvsig.data.datastores.vectorial.file.dgn.Register.selfRegister();
790
//
791
//                        DataManager dsm=DataManager.getManager();
792
//
793
//
794
//                        DataStoreParameters dp=dsm.createDataStoreParameters(DGNStore.DATASTORE_NAME);
795
//                        ((DGNStoreParameters)dp).setFile(dgnfile);
796
//                        driverTest(dp,null,null,true);
797
//                        FeatureStore fs=null;
798
//                        try {
799
//                                fs = (FeatureStore)dsm.createDataStore(dp);
800
//                        } catch (InitializeException e) {
801
//                                e.printStackTrace();
802
//                                fail("Exception:" + e);
803
//                        }
804
//                        assertNotNull("Can't create Feature Store", fs);
805
//
806
//
807
//                        fs.open();
808
//
809
//
810
//                        Iterator it;
811
//                        FeatureCollection fc;
812
//                        Comparable v1,v2;
813
//                        Feature feature,pfeature;
814
//                        long count;
815
//
816
//
817
//                        fc = (FeatureCollection)fs.getDataCollection();
818
//
819
//                        assertEquals(57, fc.size());
820
//
821
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"Color > '7'",null);
822
//
823
//                        assertEquals(45, fc.size());
824
//
825
//                        it = fc.iterator();
826
//                        count=0;
827
//                        while (it.hasNext()){
828
//                                feature = (Feature)it.next();
829
//                                assertTrue("Filter error",feature.getInt("Color")>=7);
830
//                                count++;
831
//                        }
832
//                        assertEquals("Iteration error",45,count);
833
//
834
//
835
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Layer ASC");
836
//                        assertEquals(57, fc.size());
837
//                        it = fc.iterator();
838
//                        count=0;
839
//                        pfeature = (Feature)it.next();
840
//                        count++;
841
//                        while (it.hasNext()){
842
//                                feature = (Feature)it.next();
843
//                                v1 = (Comparable)pfeature.get("Layer");
844
//                                v2 = (Comparable)feature.get("Layer");
845
//                                if (v2==null)
846
//                                        System.out.println("null");
847
//                                assertTrue("Short error", (v1.compareTo(v2) <= 0));
848
//                                pfeature=feature;
849
//                                count++;
850
//                        }
851
//                        assertEquals("Iteration error",57,count);
852
//
853
//
854
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),null,"Layer DESC");
855
//                        assertEquals(57, fc.size());
856
//                        it = fc.iterator();
857
//
858
//                        count=0;
859
//                        pfeature = (Feature)it.next();
860
//                        count++;
861
//                        while (it.hasNext()){
862
//                                feature = (Feature)it.next();
863
//                                v1 = (Comparable)pfeature.get("Layer");
864
//                                v2 = (Comparable)feature.get("Layer");
865
//                                assertTrue("Short error", (v1.compareTo(v2) >= 0));
866
//                                pfeature=feature;
867
//                                count++;
868
//                        }
869
//                        assertEquals("Iteration error",57,count);
870
//
871
//
872
//                        fc = (FeatureCollection)fs.getDataCollection(fs.getDefaultFeatureType(),"Color > '7'","Layer ASC");
873
//
874
//                        assertEquals(45, fc.size());
875
//
876
//                        it = fc.iterator();
877
//
878
//                        count=0;
879
//                        pfeature = (Feature)it.next();
880
//                        assertTrue(pfeature.getInt("Color")>7);
881
//                        count++;
882
//                        while (it.hasNext()){
883
//                                feature = (Feature)it.next();
884
//                                assertTrue("Filter error",feature.getInt("Color")>7);
885
//                                v1 = (Comparable)pfeature.get("Layer");
886
//                                v2 = (Comparable)feature.get("Layer");
887
//                                pfeature=feature;
888
//                                Integer i1=(Integer)v1;
889
//                                Integer i2=(Integer)v2;
890
//                                assertTrue("Short error", (i1.intValue()<=i2.intValue()));
891
//                                count++;
892
//                        }
893
//                        assertEquals("Iteration error",45,count);
894
//
895
//
896
//
897
////                        fc = (FeatureCollection)fs.getDataCollection(null,null,"Color,Layer Desc");
898
////                        assertEquals(10, fc.size());
899
////                        it = fc.iterator();
900
////                        count=0;
901
////                        pfeature = (Feature)it.next();
902
////                        System.out.println(pfeature.getString("Layer"));
903
////                        count++;
904
////                        while (it.hasNext()){
905
////                        feature = (Feature)it.next();
906
////                        v1 = (Comparable)((String)pfeature.get("Layer")).toLowerCase();
907
////                        v2 = (Comparable)((String)feature.get("Layer")).toLowerCase();
908
////                        pfeature=feature;
909
////                        assertTrue("Short error", (v1.compareTo(v2) >= 0));
910
////                        System.out.println(pfeature.getString("Layer"));
911
////                        count++;
912
////                        }
913
////                        assertEquals("Iteration error",10,count);
914
//
915
//
916
//                        try {
917
//                                fs.close();
918
//                        } catch (CloseException e) {
919
//                                e.printStackTrace();
920
//                                fail("Exception:" + e);
921
//                        }
922
//
923
//
924
//                        System.out.println("======= /DGN ==============");
925
//                } catch (OpenException e1) {
926
//                        e1.printStackTrace();
927
//                        fail();
928
//                } catch (ReadException e) {
929
//                        // TODO Auto-generated catch block
930
//                        e.printStackTrace();
931
//                }
932
        }
933

    
934

    
935

    
936

    
937

    
938

    
939
//        private FeatureStore createFeatureStore(IDriverParameters dp){
940
//        DataSourceManager dsm=DataSourceManager.getManager();
941

    
942
//        DataStoreParameters dsp=dsm.createDataStoreParameters(DriverStore.DATASTORE_NAME);
943

    
944
//        ((IDriverStoreParameters)dsp).setDriverParameters(dp);
945
//        FeatureStore fs=null;
946
//        try {
947
//        fs = (FeatureStore)dsm.createDataStore(dsp);
948
//        } catch (InitializeException e) {
949
//        e.printStackTrace();
950
//        fail("Exception:" + e);
951
//        }
952
//        return fs;
953

    
954
//        }
955

    
956

    
957
        private void driverTest(DataStoreParameters dp,String filter, String order,boolean testEdit){
958
//                DataManager dsm=DataManager.getManager();
959
//
960
////                DataStoreParameters dsp=dsm.createDataStoreParameters(DriverStore.DATASTORE_NAME);
961
//
962
////                ((IDriverStoreParameters)dsp).setDriverParameters(dp);
963
////                FeatureStore fs=createFeatureStore(dp);
964
//                FeatureStore fs=null;
965
//                try {
966
//                        fs = (FeatureStore)dsm.createDataStore(dp);
967
//                } catch (InitializeException e) {
968
//                        e.printStackTrace();
969
//                        fail("Exception:" + e);
970
//                }
971
//                try {
972
//                        fs.open();
973
//                } catch (OpenException e2) {
974
//                        e2.printStackTrace();
975
//                        fail();
976
//                }
977
//
978
//                if (fs.isEditable() && testEdit) {
979
//                        try {
980
//                                fs.startEditing();
981
//                                if (fs.canAlterFeatureType()){
982
//                                        FeatureType featureType=fs.getDefaultFeatureType();
983
////                                        DefaultAttributeDescriptor dad=new DefaultAttributeDescriptor();
984
////                                        dad.loading();
985
////                                        dad.setName("Prueba1");
986
////                                        dad.setDefaultValue("11p");
987
////                                        dad.setSize(10);
988
////                                        dad.setType(FeatureAttributeDescriptor.TYPE_STRING);
989
////                                        dad.stopLoading();
990
////                                        fs.insert(dad);
991
////                                        fs.delete((FeatureAttributeDescriptor)featureType.get(featureType.getFieldIndex("Prueba1")));
992
//                                        AttributeDescriptor dad2=(AttributeDescriptor)featureType.get(featureType.getFieldIndex("TIPO"));
993
//                                        dad2.editing();
994
////                                        dad2.setName("TIPO");
995
//                                        dad2.setDefaultValue("Tipop");
996
////                                        dad2.setSize(10);
997
//                                        dad2.setType(FeatureAttributeDescriptor.TYPE_STRING);
998
//                                        fs.update(dad2);
999
//                                }
1000
//                        } catch (DataException e) {
1001
//                                e.printStackTrace();fail();
1002
//                        }
1003
//                        try {
1004
//                                Feature feature1 = fs.createDefaultFeature(false);
1005
//
1006
//                                Feature feature2 = fs.createDefaultFeature(false);
1007
//                                Feature feature3 = fs.createDefaultFeature(false);
1008
//
1009
//                                fs.insert(feature1);
1010
//                                fs.insert(feature2);
1011
//
1012
//                                feature1.editing();
1013
//                                feature1.set(1,"hola");
1014
//
1015
//                                fs.update(feature1);
1016
//                                fs.delete(feature3);
1017
//                                fs.delete(feature2);
1018
//                        } catch (DataException e) {
1019
//                                // TODO Auto-generated catch block
1020
//                                e.printStackTrace();
1021
//                        }
1022
//                }
1023
//
1024
//                //Mostrar por consola todos los registros.
1025
//                FeatureType ft= fs.getDefaultFeatureType();
1026
//                FeatureCollection featureCollection=null;
1027
////                featureCollection = (FeatureCollection)fs.getDataCollection();
1028
////                featureCollection = (FeatureCollection)fs.getDataCollection(ft,"NOMBRE = 'CALPE'",null);
1029
////                featureCollection = (FeatureCollection)fs.getDataCollection(ft,"AREA > 3.2213163729E7 and AREA < 3.2213163749E7",null);
1030
//                try {
1031
//                        featureCollection = (FeatureCollection)fs.getDataCollection(ft,filter,order);
1032
//                } catch (ReadException e2) {
1033
//                        // TODO Auto-generated catch block
1034
//                        e2.printStackTrace();
1035
//                }
1036
//
1037
//                PrintlnFeaturesVisitor visitor=new PrintlnFeaturesVisitor(ft);
1038
//                try {
1039
//                        featureCollection.accept(visitor);
1040
//                } catch (BaseException e1) {
1041
//                        e1.printStackTrace();
1042
//                        fail("Exception: "+e1);
1043
//                }
1044
//
1045
//                featureCollection.dispose();
1046
//
1047
//                if (fs.isEditable() && testEdit){
1048
//                        try {
1049
//                                fs.finishEditing();
1050
//                        } catch (WriteException e) {
1051
//                                e.printStackTrace();
1052
//                                fail("Exception: "+e);
1053
//                        } catch (ReadException e) {
1054
//                                e.printStackTrace();
1055
//                                fail("Exception: "+e);
1056
//                        }
1057
//                }
1058
//                try {
1059
//                        fs.close();
1060
//                } catch (CloseException e) {
1061
//                        e.printStackTrace();
1062
//                        fail("Exception: "+e);
1063
//                }
1064
//                try {
1065
//                        fs.dispose();
1066
//                } catch (CloseException e) {
1067
//                        // TODO Auto-generated catch block
1068
//                        e.printStackTrace();
1069
//                }
1070
        }
1071

    
1072
        public static void doFileResourceTest(FileStoreParameters params) {
1073
                doFileResourceTest(params,true);
1074
        }
1075
        public static void doFileResourceTest(FileStoreParameters params,boolean testEdit){
1076
                DataManager manager = DataManager.getManager();
1077

    
1078
                ResourceManager resMan = ResourceManager.getResourceManager();
1079

    
1080
                AbstractFeatureStore store=null;
1081
                AbstractFeatureStore store2=null;
1082
                AbstractFeatureStore store3=null;
1083
                try {
1084
                        store = (AbstractFeatureStore)manager.createDataStore(params);
1085
                        store2 = (AbstractFeatureStore)manager.createDataStore(params);
1086
                        store3 = (AbstractFeatureStore)manager.createDataStore(params);
1087
                } catch (InitializeException e1) {
1088
                        e1.printStackTrace();fail();
1089
                }
1090

    
1091
                int i=0;
1092
                Resource res = null;
1093
                Resource tmpRes = null;
1094
                Object obj = null;
1095

    
1096
                Iterator iter = resMan.iterator();
1097
                while (iter.hasNext()){
1098
                        obj = iter.next();
1099
                        if (obj instanceof FileResource){
1100
                                tmpRes = (Resource)obj;
1101
                                if (((FileResource)tmpRes).getFile().getAbsoluteFile().equals(params.getFile().getAbsoluteFile())){
1102
                                        i++;
1103
                                        res=tmpRes;
1104
                                }
1105
                        }
1106
                }
1107

    
1108
                assertEquals(1, i);
1109

    
1110
                assertEquals(3, res.getRefencesCount());
1111

    
1112
                try {
1113
                        store.close();
1114
                } catch (CloseException e1) {
1115
                        e1.printStackTrace();fail();
1116
                }
1117

    
1118
                assertEquals(false, res.isOpen());
1119

    
1120
                DataCollection coll = null;
1121

    
1122
                try {
1123
                        coll =store.getDataCollection();
1124
                } catch (ReadException e1) {
1125
                        e1.printStackTrace();fail();
1126
                }
1127

    
1128
                coll.iterator().next();
1129

    
1130
                assertEquals(true, res.isOpen());
1131

    
1132
                coll.dispose();
1133

    
1134

    
1135

    
1136
                if (store.isEditable() && testEdit){
1137
                        /*Test edition notification*/
1138

    
1139
                        int fCountOrg=0;
1140
                        int fCountFin=0;
1141
                        try {
1142
                                fCountOrg = store.getDataCollection().size();
1143
                        } catch (ReadException e2) {
1144
                                // TODO Auto-generated catch block
1145
                                e2.printStackTrace();fail();
1146
                        }
1147
                        try {
1148
                                store.startEditing();
1149
                        } catch (ReadException e1) {
1150
                                e1.printStackTrace();fail();
1151
                        }
1152

    
1153
                        try {
1154
                                coll = store2.getDataCollection();
1155
                        } catch (ReadException e1) {
1156
                                e1.printStackTrace();fail();
1157
                        }
1158

    
1159
                        try {
1160
                                store.finishEditing();
1161
                        } catch (WriteException e1) {
1162
                                e1.printStackTrace();fail();
1163
                        } catch (ReadException e1) {
1164
                                // TODO Auto-generated catch block
1165
                                e1.printStackTrace();fail();
1166
                        }
1167

    
1168
                        try {
1169
                                fCountFin = store.getDataCollection().size();
1170
                        } catch (ReadException e2) {
1171
                                // TODO Auto-generated catch block
1172
                                e2.printStackTrace();fail();
1173
                        }
1174

    
1175
                        assertEquals(fCountOrg, fCountFin);
1176

    
1177

    
1178
                        boolean isOk = false;
1179
                        try{
1180
                                coll.iterator().next();
1181
                        } catch (Exception e){
1182
                                isOk=true;
1183
                        }
1184
                        assertTrue("Resource Changed Notification fails",isOk);
1185

    
1186
                        coll.dispose();
1187

    
1188

    
1189

    
1190
                        long time = System.currentTimeMillis();
1191
                        while ((System.currentTimeMillis()-time) < 1000){
1192
                                //sleep
1193
                        }
1194

    
1195

    
1196
                        ((FileResource)res).getFile().setLastModified(System.currentTimeMillis());
1197

    
1198
                        isOk=false;
1199
                        try{
1200
                                store.getDataCollection().iterator().next();
1201
                        } catch (Exception e){
1202
                                isOk=true;
1203
                        }
1204
                        assertTrue("Resource Changed Notification fails",isOk);
1205

    
1206
                        /*Test edition notification END*/
1207

    
1208
                }
1209

    
1210

    
1211

    
1212

    
1213
                try {
1214
                        store3.dispose();
1215
                } catch (CloseException e1) {
1216
                        e1.printStackTrace();fail();
1217
                }
1218

    
1219
                assertEquals(2, res.getRefencesCount());
1220

    
1221
                try {
1222
                        store2.dispose();
1223
                } catch (CloseException e1) {
1224
                        e1.printStackTrace();fail();
1225
                }
1226

    
1227
                assertEquals(1, res.getRefencesCount());
1228

    
1229
                try {
1230
                        store.dispose();
1231
                } catch (CloseException e1) {
1232
                        e1.printStackTrace();fail();
1233
                }
1234

    
1235
                assertEquals(0, res.getRefencesCount());
1236
                res = null;
1237

    
1238
                i=0;
1239
                iter = resMan.iterator();
1240
                while (iter.hasNext()){
1241
                        obj = iter.next();
1242
                        if (obj instanceof FileResource){
1243
                                tmpRes = (Resource)obj;
1244
                                if (((FileResource)tmpRes).getFile().getAbsoluteFile().equals(params.getFile().getAbsoluteFile())){
1245
                                        i++;
1246
                                        res=tmpRes;
1247
                                }
1248
                        }
1249
                }
1250

    
1251
                assertEquals(0, i);
1252

    
1253
                doPrepareFileResourceTest(params);
1254

    
1255
        }
1256

    
1257
        public static void doPrepareFileResourceTest(FileStoreParameters params){
1258
                DataManager manager = DataManager.getManager();
1259

    
1260
                ResourceManager resMan = ResourceManager.getResourceManager();
1261

    
1262
                File originalFile = params.getFile();
1263
                params.setFile(new File(originalFile.getName()));
1264

    
1265
                Observer obs = new PrepareResourceObserver(originalFile);
1266

    
1267

    
1268
                resMan.addObserver(obs);
1269

    
1270
                AbstractFeatureStore store=null;
1271
                try {
1272
                        store = (AbstractFeatureStore)manager.createDataStore(params);
1273
                } catch (InitializeException e1) {
1274
                        e1.printStackTrace();fail();
1275
                } catch (Exception e2){
1276
                        e2.printStackTrace();fail();
1277
                }
1278

    
1279
                try {
1280
                        store.getDataCollection().iterator().next();
1281
                } catch (ReadException e) {
1282
                        // TODO Auto-generated catch block
1283
                        e.printStackTrace();fail();
1284
                }
1285

    
1286
                try {
1287
                        store.close();
1288
                } catch (CloseException e) {
1289
                        // TODO Auto-generated catch block
1290
                        e.printStackTrace();fail();
1291
                }
1292
                try {
1293
                        store.dispose();
1294
                } catch (CloseException e) {
1295
                        // TODO Auto-generated catch block
1296
                        e.printStackTrace();fail();
1297
                }
1298

    
1299
        }
1300

    
1301
}