01: package org.geotools.data.postgis;
02:
03: import java.io.IOException;
04: import java.util.HashMap;
05: import java.util.Map;
06:
07: import org.geotools.data.DataStoreFinder;
08:
09: public class VersionedDataStoreStressTest extends
10: AbstractVersionedPostgisDataTestCase {
11:
12: Map remote;
13:
14: private PostgisTests.Fixture f;
15:
16: public VersionedDataStoreStressTest(String name) {
17: super (name);
18: }
19:
20: /*
21: * @see TestCase#setUp()
22: */
23: protected void setUp() throws Exception {
24: f = PostgisTests.newFixture("versioned.properties");
25: remote = new HashMap();
26: remote.put("dbtype", "postgis-versioned");
27: remote.put("charset", "");
28: remote.put("host", f.host);
29: remote.put("port", f.port);
30: remote.put("database", f.database);
31: remote.put("user", f.user);
32: remote.put("passwd", f.password);
33: remote.put("namespace", f.namespace);
34:
35: super .setUp();
36: }
37:
38: /**
39: * Versioned data store used to leak connections pretty badly due to a buglet in JCBDUtils,
40: * let's make sure this does not happen again
41: *
42: * @throws IOException
43: */
44: public void testMetadataStress() throws IOException {
45: for (int i = 0; i < 20; i++) {
46: VersionedPostgisDataStore ds = (VersionedPostgisDataStore) DataStoreFinder
47: .getDataStore(remote);
48:
49: String[] typeNames = new String[] { "road", "river", "lake" };
50: for (int j = 0; j < typeNames.length; j++) {
51: String typeName = typeNames[j];
52: ds.getSchema(typeName);
53: ds.getFeatureSource(typeName).getBounds();
54: boolean versioned = ds.isVersioned(typeName);
55: try {
56: ds.setVersioned(typeName, !versioned, "mad cow",
57: "I like to change versioning status...");
58: } catch (IOException e) {
59: // some feature types cannot be versioned, np
60: }
61: }
62: ds.dispose();
63: }
64: }
65:
66: }
|