01: /* $Id: OracleDataStoreFactoryOnlineTest.java 26153 2007-07-04 21:36:52Z chorner $
02: *
03: * Created on 4/08/2003
04: */
05: package org.geotools.data.oracle;
06:
07: import java.net.URI;
08: import java.util.HashMap;
09: import java.util.Map;
10:
11: import org.geotools.data.DataStoreFactorySpi;
12: import org.geotools.data.jdbc.ConnectionPoolManager;
13: import org.geotools.test.OnlineTestCase;
14:
15: /**
16: * Test the datastore factories
17: *
18: * @author Andrea Aime
19: */
20: public class OracleDataStoreFactoryOnlineTest extends OnlineTestCase {
21: /** The Oracle driver class name */
22: private static final String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
23: boolean GO = true;
24:
25: /**
26: * Creates a new OracleDataStoreFactoryTest Test.
27: *
28: * @throws ClassNotFoundException If the driver cannot be found
29: */
30: public OracleDataStoreFactoryOnlineTest()
31: throws ClassNotFoundException {
32: super ();
33: try {
34: Class.forName(JDBC_DRIVER);
35: } catch (Throwable t) {
36: GO = false;
37: // must be running off dummy jar!
38: }
39: }
40:
41: /**
42: * Removes the properties
43: *
44: * @throws Exception
45: * @see junit.framework.TestCase#tearDown()
46: */
47: protected void disconnect() throws Exception {
48: super .disconnect();
49: ConnectionPoolManager manager = ConnectionPoolManager
50: .getInstance();
51: manager.closeAll();
52: }
53:
54: public void testDataStoreFactory() throws Exception {
55: if (!GO)
56: return;
57: OracleDataStoreFactory factory = new OracleDataStoreFactory();
58: checkFactoryNamespace(factory);
59: }
60:
61: public void testOciDataStoreFactory() throws Exception {
62: if (!GO)
63: return;
64: OracleOCIDataStoreFactory factory = new OracleOCIDataStoreFactory();
65: checkFactoryNamespace(factory);
66: }
67:
68: public void checkFactoryNamespace(DataStoreFactorySpi factory)
69: throws Exception {
70: Map map = new HashMap();
71: map.put("host", fixture.getProperty("host"));
72: map.put("port", fixture.getProperty("port"));
73: map.put("instance", fixture.getProperty("instance"));
74: map.put("user", fixture.getProperty("user"));
75: map.put("passwd", fixture.getProperty("passwd"));
76: map.put("dbtype", "oracle");
77: map.put("alias", fixture.getProperty("instance"));
78: map.put("namespace", null);
79:
80: assertTrue(factory.canProcess(map));
81: OracleDataStore store = (OracleDataStore) factory
82: .createDataStore(map);
83: assertNull(store.getNameSpace());
84:
85: map.put("schema", fixture.getProperty("user").toUpperCase());
86: store = (OracleDataStore) factory.createDataStore(map);
87: assertNull(store.getNameSpace());
88:
89: map.put("namespace", "topp");
90: store = (OracleDataStore) factory.createDataStore(map);
91: assertEquals(new URI("topp"), store.getNameSpace());
92: }
93:
94: protected String getFixtureId() {
95: return "oracle.test";
96: }
97: }
|