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 java.sql.Connection;
20: import java.sql.SQLException;
21:
22: /**
23: * Exercise DB2CoordinateSystem.
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/DB2CoordinateSystemTest.java $
27: */
28: public class DB2CoordinateSystemTest extends DB2TestCase {
29: private Connection conn;
30:
31: /**
32: * Setup gets a database connection that will be live for the duration of
33: * all tests.
34: *
35: * @throws Exception
36: */
37: public void setUp() throws Exception {
38: super .setUp();
39: conn = getLocalConnection();
40: }
41:
42: /**
43: * Closes the database connection before we terminate.
44: *
45: * @throws Exception
46: */
47: protected void tearDown() throws Exception {
48: conn.close();
49: super .tearDown();
50: }
51:
52: public void testCreate() {
53: // Should succeed for srid 1
54: try {
55: DB2CoordinateSystem cs = new DB2CoordinateSystem(this .conn,
56: 1);
57: assertEquals("GCS_NORTH_AMERICAN_1983=EPSG:4269", cs
58: .toString());
59: } catch (SQLException e) {
60: // Shouldn't get here
61: fail("DB2CoordinateSystem constructor failed");
62: }
63:
64: // Should fail for srid -1
65: int invalidSrid = -1;
66:
67: try {
68: DB2CoordinateSystem cs = new DB2CoordinateSystem(conn,
69: invalidSrid);
70: fail("DB2CoordinateSystem constructor sucessful for invalid srid "
71: + invalidSrid);
72: } catch (SQLException e) {
73: // Should get here in successful case
74: }
75: }
76: }
|