01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-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; either
09: * version 2.1 of the License, or (at your option) any later version.
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.oracle;
17:
18: import junit.framework.TestCase;
19:
20: import org.geotools.data.DataUtilities;
21: import org.geotools.feature.FeatureType;
22: import org.geotools.feature.SchemaException;
23: import org.geotools.filter.SQLEncoderOracle;
24:
25: public class SqlStatementEncoderTest extends TestCase {
26: private SQLEncoderOracle encoder;
27:
28: private SqlStatementEncoder sql;
29:
30: protected void setUp() throws Exception {
31: encoder = new SQLEncoderOracle(4326);
32: sql = new SqlStatementEncoder(encoder, "table", "fid");
33: super .setUp();
34: }
35:
36: /*
37: * Test method for
38: * 'org.geotools.data.oracle.SqlStatementEncoder.makeCreateTableSQL(FeatureType)'
39: */
40: public void testMakeCreateTableSQL() throws Exception {
41: FeatureType schema = DataUtilities.createType("ignore",
42: "name:String, line:MultiLineString, measure:Integer");
43: String create = sql.makeCreateTableSQL(schema);
44: // System.out.println(create);
45: String expected = "CREATE TABLE table(fid NUMBER,name VARCHAR, line MDSYS.SDO_GEOMETRY, measure INTEGER)";
46: assertEquals(expected, create);
47: }
48:
49: /*
50: * Test method for
51: * 'org.geotools.data.oracle.SqlStatementEncoder.makeCreateTableSQL(FeatureType)'
52: */
53: public void testMakeCreateFixIndex() throws Exception {
54: String create = sql.makeCreateFidIndex();
55: String expected = "CREATE UNIQUE INDEX table_index ON (fid )";
56: assertEquals(expected, create);
57: }
58:
59: /*
60: * Test method for
61: * 'org.geotools.data.oracle.SqlStatementEncoder.makeCreateGeomIndex()'
62: */
63: public void testMakeCreateIndexSQL() throws SchemaException {
64: FeatureType schema = DataUtilities.createType("ignore",
65: "name:String, line:MultiLineString, measure:Integer");
66: String create = sql.makeCreateGeomIndex(schema);
67: String expected = "CREATE INDEX table_sidx ON table( line) INDEXTYPE IS mdsys.spatial_index";
68: assertEquals(expected, create);
69: }
70:
71: }
|