01: package org.geotools.data.postgis;
02:
03: import java.util.Set;
04:
05: import org.geotools.data.DefaultTransaction;
06: import org.geotools.data.FeatureStore;
07: import org.geotools.data.Transaction;
08: import org.geotools.feature.Feature;
09: import org.geotools.feature.FeatureCollection;
10: import org.geotools.feature.FeatureCollections;
11: import org.geotools.feature.FeatureType;
12:
13: public class PostgisFeatureStoreOnlineTest extends
14: AbstractPostgisOnlineTestCase {
15:
16: public void testWrite() throws Exception {
17: assertEquals(table1 + ".1", attemptWrite(table1));
18: assertEquals(table1 + ".2", attemptWrite(table1));
19: assertEquals(table2 + ".1001", attemptWrite(table2));
20: assertEquals(table2 + ".1002", attemptWrite(table2));
21: assertEquals(table3 + ".1", attemptWrite(table3));
22: assertEquals(table3 + ".2", attemptWrite(table3));
23: assertEquals(table4 + ".1000001", attemptWrite(table4));
24: assertEquals(table4 + ".1000002", attemptWrite(table4));
25: assertEquals(table5 + ".1", attemptWrite(table5));
26: assertEquals(table5 + ".2", attemptWrite(table5));
27: assertEquals(table6 + ".1001", attemptWrite(table6));
28: assertEquals(table6 + ".1002", attemptWrite(table6));
29: }
30:
31: public String attemptWrite(String table) throws Exception {
32: Transaction transaction = new DefaultTransaction(
33: "attemptWriteFS");
34: FeatureStore fs = (FeatureStore) ds.getFeatureSource(table);
35: fs.setTransaction(transaction);
36: FeatureType ft = fs.getSchema();
37: FeatureCollection fc = FeatureCollections.newCollection();
38: Feature feature = ft.create(new Object[] { "test" });
39: fc.add(feature);
40: Set set = fs.addFeatures(fc);
41: String id = (String) set.toArray()[0];
42: transaction.commit();
43:
44: return id;
45: }
46: }
|