Statistics
| Revision:

svn-gvsig-desktop / trunk / libraries / libDataSourceDBBaseDrivers / src-test / org / gvsig / data / datastores / vectorial / db / jdbc / postgresql / postgresqlTest.java @ 20029

History | View | Annotate | Download (17 KB)

1
package org.gvsig.data.datastores.vectorial.db.jdbc.postgresql;
2

    
3
import java.sql.Connection;
4
import java.sql.DriverManager;
5
import java.sql.SQLException;
6
import java.sql.Statement;
7
import java.util.Iterator;
8
import java.util.NoSuchElementException;
9

    
10
import org.gvsig.data.DataManager;
11
import org.gvsig.data.datastores.vectorial.db.jdbc.JDBCTest;
12
import org.gvsig.data.datastores.vectorial.db.jdbc.exception.JDBCDriverNotFoundException;
13
import org.gvsig.data.exception.CloseException;
14
import org.gvsig.data.exception.InitializeException;
15
import org.gvsig.data.exception.OpenException;
16
import org.gvsig.data.exception.ReadException;
17
import org.gvsig.data.exception.WriteException;
18
import org.gvsig.data.vectorial.Feature;
19
import org.gvsig.data.vectorial.IFeature;
20
import org.gvsig.data.vectorial.IFeatureAttributeDescriptor;
21
import org.gvsig.data.vectorial.IFeatureCollection;
22
import org.gvsig.data.vectorial.IFeatureStore;
23

    
24
public class postgresqlTest extends JDBCTest {
25

    
26
        private static String SERVER_IP="192.168.0.66";
27
        private static String SERVER_PORT="5432";
28
        private static String SERVER_DBNAME="gis";
29
        private static String SERVER_SCHEMA="ds_test";
30
        private static String SERVER_USER="testCase";
31
        private static String SERVER_PASWD="testCase";
32

    
33

    
34
        private static String DS_NAME = PostgresqlStore.DATASTORE_NAME;
35

    
36
        private void preparar_prueba_table() throws Exception{
37
                String url;
38
                url = "jdbc:postgresql://"+SERVER_IP+":" + SERVER_PORT +"/"+SERVER_DBNAME;
39

    
40
                Connection conn = null;
41

    
42
                Class.forName("org.postgresql.Driver");
43
                conn = DriverManager.getConnection(url, SERVER_USER, SERVER_PASWD);
44
                conn.setAutoCommit(false);
45
                Statement st = conn.createStatement();
46
                st.execute("delete from "+SERVER_SCHEMA+".prueba");
47
                st.execute("Insert into "+SERVER_SCHEMA+".prueba select * from "+SERVER_SCHEMA+".prueba_backup");
48
                st.close();
49
                conn.commit();
50
                conn.close();
51

    
52

    
53

    
54

    
55
        }
56

    
57
        public void test1(){
58
                Register.selfRegister();
59

    
60
                try {
61
                        preparar_prueba_table();
62
                } catch (Exception e) {
63
                        e.printStackTrace();
64
                        fail("Inicializando tabla prueba");
65
                }
66
                DataManager manager = DataManager.getManager();
67

    
68

    
69
                PostgresqlStoreParameters dparam =
70
                        (PostgresqlStoreParameters)manager.createDataStoreParameters(DS_NAME);
71

    
72
                dparam.setHost(SERVER_IP);
73
                dparam.setPort(SERVER_PORT);
74
                dparam.setUser(SERVER_USER);
75
                dparam.setPassw(SERVER_PASWD);
76
                dparam.setSchema(SERVER_SCHEMA);
77
                dparam.setDb(SERVER_DBNAME);
78
                dparam.setTableName("prueba");
79
                dparam.setFieldId(new String[] {"gid"});
80
                dparam.setFields(new String[] {"*"});
81
                dparam.setDefaultGeometryField("the_geom");
82

    
83
                storeTest(dparam, null, null, false);
84

    
85
        }
86

    
87
        public void testSimpleIteration38K_regs(){
88
                Register.selfRegister();
89
                DataManager manager = DataManager.getManager();
90

    
91

    
92
                PostgresqlStoreParameters dparam =
93
                        (PostgresqlStoreParameters)manager.createDataStoreParameters(DS_NAME);
94

    
95
                dparam.setHost(SERVER_IP);
96
                dparam.setPort(SERVER_PORT);
97
                dparam.setUser(SERVER_USER);
98
                dparam.setPassw(SERVER_PASWD);
99
                dparam.setSchema(null);
100
                dparam.setDb(SERVER_DBNAME);
101
                dparam.setTableName("hidropol");
102
//                dparam.setTableName("ejes");
103
                dparam.setFieldId(new String[] {"gid"});
104
                dparam.setFields(new String[] {"*"});
105
                dparam.setDefaultGeometryField("the_geom");
106

    
107
//                storeTest(dparam, null, null, false);
108

    
109
                IFeatureStore fs=null;
110
                try {
111
                        fs = (IFeatureStore) manager.createDataStore(dparam);
112
                } catch (InitializeException e) {
113
                        e.printStackTrace();
114
                        fail();
115
                }
116
                IFeatureCollection fc=null;
117
                try {
118
                        fc = (IFeatureCollection) fs.getDataCollection();
119
                } catch (ReadException e) {
120
                        e.printStackTrace();
121
                        fail();
122
                }
123

    
124
                int i=0;
125
                int count = fc.size();
126
                Iterator iter = fc.iterator();
127
                while (true){
128
                        try{
129
                                iter.next();
130
                                i++;
131
                        } catch (NoSuchElementException e) {
132
                                break;
133
                        }
134
                }
135
                assertEquals(count, i);
136

    
137
                fc.dispose();
138

    
139
                try {
140
                        fs.close();
141
                } catch (CloseException e) {
142
                        e.printStackTrace();
143
                        fail("Exception: "+e);
144
                }
145
                try {
146
                        fs.dispose();
147
                } catch (CloseException e) {
148
                        // TODO Auto-generated catch block
149
                        e.printStackTrace();
150
                }
151

    
152

    
153
        }
154

    
155
        public void test__sqlMode(){
156
                Register.selfRegister();
157
                DataManager manager = DataManager.getManager();
158

    
159

    
160
                PostgresqlStoreParameters dparam =
161
                        (PostgresqlStoreParameters)manager.createDataStoreParameters(DS_NAME);
162

    
163
                dparam.setHost(SERVER_IP);
164
                dparam.setPort(SERVER_PORT);
165
                dparam.setUser(SERVER_USER);
166
                dparam.setPassw(SERVER_PASWD);
167
                dparam.setSchema(SERVER_SCHEMA);
168
                dparam.setDb(SERVER_DBNAME);
169
//                dparam.setTableName("prueba");
170
                dparam.setSqlSoure("Select * from "+ SERVER_SCHEMA+".prueba");
171
                dparam.setFieldId(new String[] {"gid"});
172
                dparam.setFields(new String[] {"*"});
173
                dparam.setDefaultGeometryField("the_geom");
174

    
175
                storeTest(dparam, null, null, false);
176

    
177
                Exception exc = null;
178

    
179
                IFeatureStore fs=null;
180
                try {
181
                        fs = (IFeatureStore)manager.createDataStore(dparam);
182
                } catch (InitializeException e) {
183
                        e.printStackTrace();
184
                        fail("Exception:" + e);
185
                }
186
                assertNotNull("Can't create Feature Store", fs);
187

    
188
                try {
189
                        fs.open();
190
                } catch (OpenException e2) {
191
                        e2.printStackTrace();
192
                        fail();
193
                }
194

    
195

    
196
                Iterator it;
197
                IFeatureCollection fc =null;
198

    
199
                try {
200
                        fc = (IFeatureCollection)fs.getDataCollection();
201
                } catch (ReadException e1) {
202
                        e1.printStackTrace();
203
                        fail();
204
                }
205

    
206
                assertEquals(9, fc.size());
207

    
208
                fc.dispose();
209

    
210
                assertFalse("Edition allowed in sqlSource mode", fs.isEditable());
211

    
212
                try {
213
                        fs.startEditing();
214
                } catch (ReadException e1) {
215
                        exc=e1;
216
                }
217
                assertNotNull("Edition allowed in sqlSource mode",exc);
218

    
219
                exc=null;
220
                try {
221
                        fc = (IFeatureCollection)fs.getDataCollection(null,"nombre like 'B%'",null);
222
                } catch (ReadException e1) {
223
                        exc=e1;
224
                }
225
                assertNotNull("Filter allowed in sqlSource mode",exc);
226

    
227
                exc=null;
228
                try {
229
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"nombre");
230
                } catch (ReadException e1) {
231
                        exc=e1;
232
                }
233
                assertNotNull("Order allowed in sqlSource mode",exc);
234

    
235

    
236
                try {
237
                        fs.close();
238
                } catch (CloseException e) {
239
                        e.printStackTrace();
240
                        fail("Exception:" + e);
241
                }
242

    
243
        }
244

    
245
        public void test2(){
246

    
247
                try {
248
                        preparar_prueba_table();
249
                } catch (Exception e) {
250
                        e.printStackTrace();
251
                        fail("Inicializando tabla prueba");
252
                }
253

    
254
                Register.selfRegister();
255
                DataManager manager = DataManager.getManager();
256

    
257

    
258
                PostgresqlStoreParameters dparam =
259
                        (PostgresqlStoreParameters)manager.createDataStoreParameters(DS_NAME);
260

    
261
                dparam.setHost(SERVER_IP);
262
                dparam.setPort(SERVER_PORT);
263
                dparam.setUser(SERVER_USER);
264
                dparam.setPassw(SERVER_PASWD);
265
                dparam.setSchema(SERVER_SCHEMA);
266
                dparam.setDb(SERVER_DBNAME);
267
                dparam.setTableName("prueba");
268
                dparam.setFieldId(new String[] {"gid"});
269
                dparam.setFields(new String[] {"*"});
270
                dparam.setDefaultGeometryField("the_geom");
271

    
272
//                storeTest(dparam, null, null, true);
273
                storeTest(dparam, null, null, false);
274

    
275
                IFeatureStore fs=null;
276
                try {
277
                        fs = (IFeatureStore)manager.createDataStore(dparam);
278
                } catch (InitializeException e) {
279
                        e.printStackTrace();
280
                        fail("Exception:" + e);
281
                }
282
                assertNotNull("Can't create Feature Store", fs);
283

    
284
                try {
285
                        fs.open();
286
                } catch (OpenException e2) {
287
                        e2.printStackTrace();
288
                        fail();
289
                }
290

    
291
                Iterator it;
292
                IFeatureCollection fc =null;
293
                Comparable v1,v2;
294
                IFeature feature,pfeature;
295
                long count;
296

    
297

    
298
                try {
299
                        fc = (IFeatureCollection)fs.getDataCollection();
300
                } catch (ReadException e1) {
301
                        e1.printStackTrace();
302
                        fail();
303
                }
304

    
305
                assertEquals(9, fc.size());
306

    
307
                fc.dispose();
308

    
309
                try {
310
                        fc = (IFeatureCollection)fs.getDataCollection(null,"lower(nombre) like 'b%'",null);
311
                } catch (ReadException e1) {
312
                        e1.printStackTrace();
313
                        fail();
314
                }
315

    
316
                assertEquals(2, fc.size());
317

    
318
                it = fc.iterator();
319
                count=0;
320
                while (it.hasNext()){
321
                        feature = (IFeature)it.next();
322
                        assertTrue("Filter error",feature.getString("nombre").toLowerCase().startsWith("b"));
323
                        count++;
324
                }
325
                assertEquals("Iteration error",2,count);
326

    
327
                fc.dispose();
328

    
329

    
330
                try {
331
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"nombre ASC");
332
                } catch (ReadException e1) {
333
                        e1.printStackTrace();
334
                        fail();
335
                }
336
                assertEquals(9, fc.size());
337
                it = fc.iterator();
338
                count=0;
339
                pfeature = (IFeature)it.next();
340
                count++;
341
                while (it.hasNext()){
342
                        feature = (IFeature)it.next();
343
                        v1 = (Comparable)pfeature.get("nombre");
344
                        v2 = (Comparable)feature.get("nombre");
345
                        pfeature=feature;
346
                        assertTrue("Short error", (v1.compareTo(v1) <= 0));
347
                        count++;
348
                }
349
                assertEquals("Iteration error",9,count);
350

    
351
                fc.dispose();
352

    
353

    
354
                try {
355
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"nombre DESC");
356
                } catch (ReadException e1) {
357
                        e1.printStackTrace();
358
                        fail();
359
                }
360
                assertEquals(9, fc.size());
361
                it = fc.iterator();
362

    
363
                count=0;
364
                pfeature = (IFeature)it.next();
365
                count++;
366
                while (it.hasNext()){
367
                        feature = (IFeature)it.next();
368
                        v1 = (Comparable)pfeature.get("nombre");
369
                        v2 = (Comparable)feature.get("nombre");
370
                        pfeature=feature;
371
                        assertTrue("Short error", (v1.compareTo(v1) >= 0));
372
                        count++;
373
                }
374
                assertEquals("Iteration error",9,count);
375

    
376
                fc.dispose();
377

    
378

    
379

    
380
                try {
381
                        fc = (IFeatureCollection)fs.getDataCollection(null,"lower(nombre) like 'b%'","nombre");
382
                } catch (ReadException e1) {
383
                        e1.printStackTrace();
384
                        fail();
385
                }
386

    
387
                assertEquals(2, fc.size());
388

    
389
                it = fc.iterator();
390

    
391
                count=0;
392
                pfeature = (IFeature)it.next();
393
                assertTrue(pfeature.getString("nombre").toLowerCase().startsWith("b"));
394
                count++;
395
                while (it.hasNext()){
396
                        feature = (IFeature)it.next();
397
                        assertTrue("Filter error",feature.getString("nombre").toLowerCase().startsWith("b"));
398
                        v1 = (Comparable)pfeature.get("nombre");
399
                        v2 = (Comparable)feature.get("nombre");
400
                        pfeature=feature;
401
                        assertTrue("Short error", (v1.compareTo(v1) <= 0));
402
                        count++;
403
                }
404
                assertEquals("Iteration error",2,count);
405
                fc.dispose();
406

    
407

    
408

    
409
                try {
410
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(nombre) Desc");
411
                } catch (ReadException e1) {
412
                        e1.printStackTrace();
413
                        fail();
414
                }
415
                assertEquals(9, fc.size());
416
                it = fc.iterator();
417
                count=0;
418
                pfeature = (IFeature)it.next();
419
                System.out.println(pfeature.getString("nombre"));
420
                count++;
421
                while (it.hasNext()){
422
                        feature = (IFeature)it.next();
423
                        v1 = (Comparable)((String)pfeature.get("nombre")).toLowerCase();
424
                        v2 = (Comparable)((String)feature.get("nombre")).toLowerCase();
425
                        pfeature=feature;
426
                        assertTrue("Short error", (v1.compareTo(v2) >= 0));
427
                        System.out.println(pfeature.getString("nombre"));
428
                        count++;
429
                }
430
                assertEquals("Iteration error",9,count);
431
                fc.dispose();
432

    
433

    
434

    
435
                /// CON  EDICION
436
                try {
437
                        fs.startEditing();
438
                } catch (ReadException e1) {
439
                        e1.printStackTrace();
440
                        fail();
441
                }
442

    
443

    
444
                IFeature newFeature = fs.createFeature(fs.getDefaultFeatureType());
445
                newFeature.set("nombre","BuRjaSOT");
446
                newFeature.set("tipo","MUNICIPIO");
447
                fs.insert(newFeature);
448

    
449

    
450
                try {
451
                        fc = (IFeatureCollection)fs.getDataCollection();
452
                } catch (ReadException e1) {
453
                        e1.printStackTrace();
454
                        fail();
455
                }
456

    
457
                assertEquals(10, fc.size());
458
                fc.dispose();
459

    
460
                try {
461
                        fc = (IFeatureCollection)fs.getDataCollection(null,"lower(nombre) like 'b%'",null);
462
                } catch (ReadException e1) {
463
                        e1.printStackTrace();
464
                        fail();
465
                }
466

    
467
                assertEquals(3, fc.size());
468

    
469
                it = fc.iterator();
470
                count=0;
471
                while (it.hasNext()){
472
                        feature = (IFeature)it.next();
473
                        assertTrue("Filter error",feature.getString("nombre").toLowerCase().startsWith("b"));
474
                        count++;
475
                }
476
                assertEquals("Iteration error",3,count);
477
                fc.dispose();
478

    
479

    
480
                try {
481
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"nombre ASC");
482
                } catch (ReadException e1) {
483
                        e1.printStackTrace();
484
                        fail();
485
                }
486
                assertEquals(10, fc.size());
487
                it = fc.iterator();
488
                count=0;
489
                pfeature = (IFeature)it.next();
490
                count++;
491
                while (it.hasNext()){
492
                        feature = (IFeature)it.next();
493
                        v1 = (Comparable)pfeature.get("nombre");
494
                        v2 = (Comparable)feature.get("nombre");
495
                        pfeature=feature;
496
                        assertTrue("Short error", (v1.compareTo(v1) <= 0));
497
                        count++;
498
                }
499
                assertEquals("Iteration error",10,count);
500
                fc.dispose();
501

    
502

    
503
                try {
504
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"nombre DESC");
505
                } catch (ReadException e1) {
506
                        e1.printStackTrace();
507
                        fail();
508
                }
509
                assertEquals(10, fc.size());
510
                it = fc.iterator();
511

    
512
                count=0;
513
                pfeature = (IFeature)it.next();
514
                count++;
515
                while (it.hasNext()){
516
                        feature = (IFeature)it.next();
517
                        v1 = (Comparable)pfeature.get("nombre");
518
                        v2 = (Comparable)feature.get("nombre");
519
                        pfeature=feature;
520
                        assertTrue("Short error", (v1.compareTo(v1) >= 0));
521
                        count++;
522
                }
523
                assertEquals("Iteration error",10,count);
524
                fc.dispose();
525

    
526

    
527
                try {
528
                        fc = (IFeatureCollection)fs.getDataCollection(null,"lower(nombre) like 'b%'","nombre");
529
                } catch (ReadException e1) {
530
                        e1.printStackTrace();
531
                        fail();
532
                }
533

    
534
                assertEquals(3, fc.size());
535

    
536
                it = fc.iterator();
537

    
538
                count=0;
539
                pfeature = (IFeature)it.next();
540
                assertTrue(pfeature.getString("nombre").toLowerCase().startsWith("b"));
541
                count++;
542
                while (it.hasNext()){
543
                        feature = (IFeature)it.next();
544
                        assertTrue("Filter error",feature.getString("nombre").toLowerCase().startsWith("b"));
545
                        v1 = (Comparable)pfeature.get("nombre");
546
                        v2 = (Comparable)feature.get("nombre");
547
                        pfeature=feature;
548
                        assertTrue("Short error", (v1.compareTo(v1) <= 0));
549
                        count++;
550
                }
551
                assertEquals("Iteration error",3,count);
552
                fc.dispose();
553

    
554

    
555

    
556
                try {
557
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"Tipo,lower(nombre) Desc");
558
                } catch (ReadException e1) {
559
                        e1.printStackTrace();
560
                        fail();
561
                }
562
                assertEquals(10, fc.size());
563
                it = fc.iterator();
564
                count=0;
565
                pfeature = (IFeature)it.next();
566
                System.out.println(pfeature.getString("nombre"));
567
                count++;
568
                while (it.hasNext()){
569
                        feature = (IFeature)it.next();
570
                        v1 = (Comparable)((String)pfeature.get("nombre")).toLowerCase();
571
                        v2 = (Comparable)((String)feature.get("nombre")).toLowerCase();
572
                        pfeature=feature;
573
                        assertTrue("Short error", (v1.compareTo(v2) >= 0));
574
                        System.out.println(pfeature.getString("nombre"));
575
                        count++;
576
                }
577
                assertEquals("Iteration error",10,count);
578
                fc.dispose();
579

    
580

    
581
                fs.cancelEditing();
582

    
583

    
584
                //Insertar un elemento
585
                try{
586
                        fs.startEditing();
587
                } catch (ReadException e1) {
588
                        e1.printStackTrace();
589
                        fail();
590
                }
591

    
592
                feature = fs.createDefaultFeature(true);
593
//                feature.set("id", 90000);
594
                feature.set("nombre","BurJASOT");
595
                feature.set("tipo", "OTRO");
596
                fs.insert(feature);
597

    
598
                try {
599
                        fs.finishEditing();
600
                } catch (WriteException e) {
601
                        e.printStackTrace();
602
                        fail("Exception: "+e);
603
                } catch (ReadException e) {
604
                        e.printStackTrace();
605
                        fail("Exception: "+e);
606
                }
607

    
608

    
609
                try {
610
                        fc = (IFeatureCollection)fs.getDataCollection(null,null,"lower(nombre) Desc");
611
                } catch (ReadException e1) {
612
                        e1.printStackTrace();
613
                        fail();
614
                }
615
                assertEquals(10, fc.size());
616
                it = fc.iterator();
617
                count=0;
618
                pfeature = (IFeature)it.next();
619
                System.out.println(pfeature.getString("nombre"));
620
                count++;
621
                while (it.hasNext()){
622
                        feature = (IFeature)it.next();
623
                        v1 = (Comparable)((String)pfeature.get("nombre")).toLowerCase();
624
                        v2 = (Comparable)((String)feature.get("nombre")).toLowerCase();
625
                        pfeature=feature;
626
                        assertTrue("Short error: "+ v1.toString() + " >= " +v2.toString(), (v1.compareTo(v2) >= 0));
627
                        System.out.println(pfeature.getString("nombre"));
628
                        count++;
629
                }
630
                assertEquals("Iteration error",10,count);
631
                fc.dispose();
632

    
633

    
634

    
635
                //Actualizacion
636
                try{
637
                        fs.startEditing();
638
                } catch (ReadException e1) {
639
                        e1.printStackTrace();
640
                        fail();
641
                }
642

    
643

    
644
                try {
645
                        fc = (IFeatureCollection)fs.getDataCollection(null,"lower(nombre) = 'burjasot'",null);
646
                } catch (ReadException e1) {
647
                        e1.printStackTrace();
648
                        fail();
649
                }
650
                assertEquals(1, fc.size());
651
                Feature old =(Feature)fc.iterator().next();
652
                feature = fs.createDefaultFeature(false);
653
                it = fs.getDefaultFeatureType().iterator();
654
                IFeatureAttributeDescriptor attr;
655
                while(it.hasNext()){
656
                         attr = (IFeatureAttributeDescriptor)it.next();
657
//                         if (attr.getDataType() == IFeatureAttributeDescriptor.TYPE_GEOMETRY){
658
//                                 feature.set(attr.getName(), old.get(attr.getName()));
659
//                         } else {
660
                                 feature.set(attr.getName(), old.get(attr.getName()));
661
//                         }
662
                }
663
                feature.set("nombre", feature.getString("nombre")+"__KK__");
664

    
665
                fs.update(feature, old);
666
                try {
667
                        fs.finishEditing();
668
                } catch (WriteException e) {
669
                        e.printStackTrace();
670
                        fail("Exception: "+e);
671
                } catch (ReadException e) {
672
                        e.printStackTrace();
673
                        fail("Exception: "+e);
674
                }
675

    
676
                try {
677
                        fc = (IFeatureCollection)fs.getDataCollection(null,"nombre like '%__KK__'",null);
678
                } catch (ReadException e1) {
679
                        e1.printStackTrace();
680
                        fail();
681
                }
682
                assertEquals(1, fc.size());
683
                fc.dispose();
684

    
685

    
686
                //Eliminacion
687
                try{
688
                        fs.startEditing();
689
                } catch (ReadException e1) {
690
                        e1.printStackTrace();
691
                        fail();
692
                }
693

    
694

    
695
                try {
696
                        fc = (IFeatureCollection)fs.getDataCollection(null,"nombre like '%__KK__'",null);
697
                } catch (ReadException e1) {
698
                        e1.printStackTrace();
699
                        fail();
700
                }
701
                assertEquals(1, fc.size());
702
                fs.delete((IFeature)fc.iterator().next());
703
                fc.dispose();
704
                try {
705
                        fs.finishEditing();
706
                } catch (WriteException e) {
707
                        e.printStackTrace();
708
                        fail("Exception: "+e);
709
                } catch (ReadException e) {
710
                        e.printStackTrace();
711
                        fail("Exception: "+e);
712
                }
713

    
714
                try {
715
                        fc = (IFeatureCollection)fs.getDataCollection();
716
                } catch (ReadException e1) {
717
                        e1.printStackTrace();
718
                        fail();
719
                }
720
                assertEquals(9, fc.size());
721
                fc.dispose();
722

    
723

    
724

    
725
                try {
726
                        fs.close();
727
                } catch (CloseException e) {
728
                        e.printStackTrace();
729
                        fail("Exception:" + e);
730
                }
731

    
732

    
733

    
734
        }
735

    
736

    
737
}