01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2002-2007, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.data.postgis;
17:
18: import java.util.HashMap;
19: import java.util.Map;
20:
21: import org.geotools.data.DataStore;
22: import org.geotools.test.OnlineTestCase;
23:
24: /**
25: * Abstract class for PostGIS online test cases.
26: *
27: * @since 2.4
28: * @author Cory Horner, Refractions Research
29: */
30: public abstract class PostgisOnlineTestCase extends OnlineTestCase {
31:
32: protected DataStore dataStore;
33:
34: protected abstract String getFixtureId();
35:
36: protected void connect() throws Exception {
37: Map params = getParams();
38: dataStore = new PostgisDataStoreFactory()
39: .createDataStore(params);
40: }
41:
42: public Map getParams() {
43: Map params = new HashMap();
44:
45: params.put(PostgisDataStoreFactory.DBTYPE.key, "postgis");
46: params.put(PostgisDataStoreFactory.HOST.key, fixture
47: .getProperty("host"));
48: params.put(PostgisDataStoreFactory.PORT.key, fixture
49: .getProperty("port"));
50: params.put(PostgisDataStoreFactory.SCHEMA.key, fixture
51: .getProperty("schema"));
52: params.put(PostgisDataStoreFactory.DATABASE.key, fixture
53: .getProperty("database"));
54: params.put(PostgisDataStoreFactory.USER.key, fixture
55: .getProperty("user"));
56: params.put(PostgisDataStoreFactory.PASSWD.key, fixture
57: .getProperty("password"));
58:
59: if (fixture.containsKey("wkbEnabled")) {
60: params.put(PostgisDataStoreFactory.WKBENABLED.key, fixture
61: .getProperty("wkbEnabled"));
62: }
63: if (fixture.containsKey("looseBbox")) {
64: params.put(PostgisDataStoreFactory.LOOSEBBOX.key, fixture
65: .getProperty("looseBbox"));
66: }
67:
68: return params;
69: }
70:
71: protected void disconnect() throws Exception {
72: dataStore = null;
73: }
74:
75: }
|