01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2005-2006, 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 junit.framework.TestCase;
22:
23: import org.geotools.data.DataSourceException;
24: import org.geotools.data.DataStore;
25: import org.geotools.data.DataStoreFinder;
26:
27: /**
28: * Test Params used by PostgisDataStoreFactory.
29: *
30: * @author aaime
31: * @author $Author: jive $ (last modification)
32: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/postgis-versioned/src/test/java/org/geotools/data/postgis/VersiondPostgisDataStoreFactoryOnlineTest.java $
33: * @version $Id: VersiondPostgisDataStoreFactoryOnlineTest.java 24679 2007-03-05 19:13:33Z aaime $
34: */
35: public class VersiondPostgisDataStoreFactoryOnlineTest extends TestCase {
36: static VersionedPostgisDataStoreFactory factory = new VersionedPostgisDataStoreFactory();
37:
38: Map remote;
39: Map local;
40:
41: private PostgisTests.Fixture f;
42:
43: /*
44: * @see TestCase#setUp()
45: */
46: protected void setUp() throws Exception {
47:
48: f = PostgisTests.newFixture("versioned.properties");
49: remote = new HashMap();
50: remote.put("dbtype", "postgis-versioned");
51: remote.put("charset", "");
52: remote.put("host", f.host);
53: remote.put("port", f.port);
54: remote.put("database", f.database);
55: remote.put("user", f.user);
56: remote.put("passwd", f.password);
57: remote.put("namespace", f.namespace);
58:
59: super .setUp();
60: }
61:
62: public void testRemote() throws Exception {
63: Map map = remote;
64:
65: assertEquals(f.database, factory.DATABASE.lookUp(map));
66: assertEquals("postgis-versioned", factory.DBTYPE.lookUp(map));
67: assertEquals(f.host, factory.HOST.lookUp(map));
68: assertEquals(f.namespace, factory.NAMESPACE.lookUp(map));
69: assertEquals(f.password, factory.PASSWD.lookUp(map));
70: assertEquals(f.port, factory.PORT.lookUp(map));
71: assertEquals(f.user, factory.USER.lookUp(map));
72:
73: assertTrue("canProcess", factory.canProcess(map));
74: try {
75: DataStore temp = factory.createDataStore(map);
76: assertNotNull("created", temp);
77: } catch (DataSourceException expected) {
78: assertTrue(expected.getMessage().startsWith(
79: "Connection failed:"));
80: }
81: }
82:
83: public void testLookup() throws Exception {
84: DataStore ds = DataStoreFinder.getDataStore(remote);
85: assertNotNull(ds);
86: assertTrue(ds instanceof VersionedPostgisDataStore);
87: }
88:
89: public void testVersioned() throws Exception {
90: remote.put("version enable all", Boolean.TRUE);
91: VersionedPostgisDataStore ds = (VersionedPostgisDataStore) DataStoreFinder
92: .getDataStore(remote);
93: assertTrue(ds.isVersioned("road"));
94: assertTrue(ds.isVersioned("river"));
95: }
96: }
|