01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) Copyright IBM Corporation, 2005. All rights reserved.
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: */
17: package org.geotools.data.db2;
18:
19: import org.geotools.data.jdbc.JDBCDataStoreConfig;
20: import java.io.IOException;
21:
22: /**
23: * Exercise DB2DataStore.
24: *
25: * @author David Adler - IBM Corporation
26: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/db2/src/test/java/org/geotools/data/db2/DB2DataStoreTest.java $
27: */
28: public class DB2DataStoreTest extends DB2TestCase {
29: /**
30: * Setup gets a database connection that will be live for the duration of
31: * all tests.
32: *
33: * @throws Exception
34: */
35: public void setUp() throws Exception {
36: super .setUp();
37: pool = getLocalConnectionPool();
38: }
39:
40: /**
41: * Closes the database connection before we terminate.
42: *
43: * @throws Exception
44: */
45: protected void tearDown() throws Exception {
46: // pool.close();
47: super .tearDown();
48: }
49:
50: public void testNewDBDataStore() throws Exception {
51: JDBCDataStoreConfig config = new JDBCDataStoreConfig(tabSchema,
52: tabSchema, 100000);
53:
54: try {
55: DB2DataStore dataStore = new DB2DataStore(null, config,
56: getDbURL());
57: fail("new DB2DataStore should have failed for null connection pool");
58: } catch (IOException e) {
59: }
60:
61: DB2DataStore dataStore = null;
62:
63: try {
64: dataStore = new DB2DataStore(pool, config, getDbURL());
65: } catch (IOException e) {
66: fail("new DB2DataStore shouldn't have failed");
67: }
68:
69: assertEquals(getDbURL(), dataStore.getDbURL());
70: }
71:
72: public void testEntity() throws Exception {
73: DB2DataStore dataStore = getDataStore();
74: String[] typeNames = dataStore.getTypeNames();
75: int foundCount = 0;
76:
77: for (int i = 0; i < typeNames.length; i++) {
78: if (typeNames[i].equals("Places")) {
79: foundCount++;
80: }
81:
82: if (typeNames[i].equals("Roads")) {
83: foundCount++;
84: }
85: }
86:
87: assertTrue(foundCount == 2);
88: }
89: }
|