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:
26: /**
27: * Test Params used by PostgisDataStoreFactory.
28: *
29: * @author jgarnett, Refractions Research, Inc.
30: * @author $Author: jive $ (last modification)
31: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/postgis/src/test/java/org/geotools/data/postgis/PostgisDataStoreFactoryOnlineTest.java $
32: * @version $Id: PostgisDataStoreFactoryOnlineTest.java 20877 2006-08-07 12:58:33Z jgarnett $
33: */
34: public class PostgisDataStoreFactoryOnlineTest extends TestCase {
35: static PostgisDataStoreFactory factory = new PostgisDataStoreFactory();
36:
37: Map remote;
38: Map local;
39:
40: private PostgisTests.Fixture f;
41:
42: /*
43: * @see TestCase#setUp()
44: */
45: protected void setUp() throws Exception {
46:
47: f = PostgisTests.newFixture();
48: remote = new HashMap();
49: remote.put("dbtype", "postgis");
50: remote.put("charset", "");
51: remote.put("host", f.host);
52: remote.put("port", f.port);
53: remote.put("database", f.database);
54: remote.put("user", f.user);
55: remote.put("passwd", f.password);
56: remote.put("namespace", f.namespace);
57:
58: super .setUp();
59: }
60:
61: public void testRemote() throws Exception {
62: Map map = remote;
63:
64: assertEquals(f.database, factory.DATABASE.lookUp(map));
65: assertEquals("postgis", factory.DBTYPE.lookUp(map));
66: assertEquals(f.host, factory.HOST.lookUp(map));
67: assertEquals(f.namespace, factory.NAMESPACE.lookUp(map));
68: assertEquals(f.password, factory.PASSWD.lookUp(map));
69: assertEquals(f.port, factory.PORT.lookUp(map));
70: assertEquals(f.user, factory.USER.lookUp(map));
71:
72: assertTrue("canProcess", factory.canProcess(map));
73: try {
74: DataStore temp = factory.createDataStore(map);
75: assertNotNull("created", temp);
76: } catch (DataSourceException expected) {
77: assertTrue(expected.getMessage().startsWith(
78: "Connection failed:"));
79: }
80: }
81: }
|