Source Code Cross Referenced for QuickOracleOnlineTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » oracle » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.data.oracle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.data.oracle;
017:
018:        import java.io.IOException;
019:        import java.sql.Connection;
020:        import java.sql.ResultSet;
021:        import java.sql.ResultSetMetaData;
022:        import java.sql.SQLException;
023:        import java.sql.Statement;
024:        import java.util.Properties;
025:        import java.util.PropertyResourceBundle;
026:        import java.util.logging.Logger;
027:
028:        import oracle.sql.ARRAY;
029:        import oracle.sql.Datum;
030:        import oracle.sql.STRUCT;
031:
032:        import org.geotools.data.DataStoreFinder;
033:        import org.geotools.data.DataTestCase;
034:        import org.geotools.data.jdbc.ConnectionPool;
035:        import org.geotools.data.jdbc.ConnectionPoolManager;
036:        import org.geotools.data.jdbc.JDBCDataStoreConfig;
037:        import org.geotools.feature.FeatureType;
038:        import org.geotools.feature.GeometryAttributeType;
039:        import org.geotools.geometry.jts.ReferencedEnvelope;
040:        import org.geotools.referencing.CRS;
041:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
042:
043:        import com.vividsolutions.jts.geom.Envelope;
044:
045:        /**
046:         * This class provides a quick test of OracleDataStore.
047:         * <p>
048:         * We are using this class to test the internal workings of the
049:         * OracleDataStore.  To test the public "normal" api please
050:         * refer to OracleDataStoreTest.
051:         * </p>
052:         * <p>
053:         * Several of these tests bay be "X"ed out, in such cases
054:         * the tests were serving as a scratch pad as we learned where oracle
055:         * keeps everything.
056:         * </p>
057:         * @author Jody Garnett, Refractions Research
058:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/oracle-spatial/src/test/java/org/geotools/data/oracle/QuickOracleOnlineTest.java $
059:         */
060:        public class QuickOracleOnlineTest extends DataTestCase {
061:
062:            /** The logger for the filter module. */
063:            private static final Logger LOGGER = org.geotools.util.logging.Logging
064:                    .getLogger("org.geotools.data.postgis");
065:
066:            OracleDataStore data;
067:            ConnectionPool pool;
068:
069:            private Connection conn;
070:
071:            /**
072:             * Constructor for MemoryDataStoreTest.
073:             *
074:             * @param test
075:             *
076:             * @throws AssertionError DOCUMENT ME!
077:             */
078:            public QuickOracleOnlineTest(String test) {
079:                super (test);
080:            }
081:
082:            protected void setUp() throws Exception {
083:                super .setUp();
084:
085:                Properties resource = new Properties();
086:                resource.load(this .getClass().getResourceAsStream(
087:                        "remote.properties"));
088:
089:                data = (OracleDataStore) DataStoreFinder.getDataStore(resource);
090:
091:                //BasicFIDMapper basic = new BasicFIDMapper("tid", 255, false);
092:                //TypedFIDMapper typed = new TypedFIDMapper( basic, "trim_utm10");
093:                //data.setFIDMapper("trim_utm10", typed );        
094:            }
095:
096:            boolean create = true;
097:
098:            protected void reset() throws Exception {
099:                if (conn == null)
100:                    return;
101:
102:                if (!create)
103:                    return;
104:                Statement st = conn.createStatement();
105:
106:                if (st
107:                        .executeQuery(
108:                                "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME = 'ORA_TEST_LINES'")
109:                        .next()) {
110:                    try {
111:                        st.execute("DROP TABLE ORA_TEST_LINES");
112:                        st
113:                                .executeUpdate("DELETE FROM user_sdo_geom_metadata WHERE TABLE_NAME='ORA_TEST_LINES'");
114:                    } catch (SQLException noPrevRun) {
115:                        noPrevRun.printStackTrace();
116:                    }
117:                }
118:                try {
119:                    st.execute("CREATE TABLE ORA_TEST_LINES ("
120:                            + "    name    VARCHAR(255),"
121:                            + "    intval  NUMBER,"
122:                            + "    id      NUMBER  PRIMARY KEY,"
123:                            + "    shape   MDSYS.SDO_GEOMETRY" + ")");
124:                    st
125:                            .execute("INSERT INTO USER_SDO_GEOM_METADATA VALUES ("
126:                                    + "    'ORA_TEST_LINES',"
127:                                    + "    'SHAPE',"
128:                                    + "    MDSYS.SDO_DIM_ARRAY("
129:                                    + "        MDSYS.SDO_DIM_ELEMENT('X',-180,180,0.005),"
130:                                    + "        MDSYS.SDO_DIM_ELEMENT('Y',-90,90,0.005)"
131:                                    + "    )," + "    82465" + ")");
132:                    st
133:                            .execute("create index test_line_index on ORA_TEST_LINES(SHAPE) INDEXTYPE IS MDSYS.SPATIAL_INDEX");
134:                    //
135:                    // If we ever need data we can do it here!
136:                    // but right now we are just hammering Schema
137:                } catch (SQLException fine) {
138:                    fine.printStackTrace();
139:                }
140:                create = false;
141:            }
142:
143:            protected void tearDown() throws Exception {
144:                if (conn != null)
145:                    conn.close();
146:                if (pool != null)
147:                    pool.close();
148:
149:                ConnectionPoolManager manager = ConnectionPoolManager
150:                        .getInstance();
151:                manager.closeAll();
152:
153:                conn = null;
154:                pool = null;
155:                data = null;
156:                super .tearDown();
157:            }
158:
159:            public void testSRIDLookup() throws Exception {
160:                if (conn == null)
161:                    return;
162:
163:                Statement st = conn.createStatement();
164:                st
165:                        .execute("select cs_name, wktext from cs_srs where srid = 82465");
166:
167:                ResultSet set = st.getResultSet();
168:                ResultSetMetaData meta = set.getMetaData();
169:                assertEquals(2, meta.getColumnCount());
170:                assertTrue(set.next());
171:
172:                String name = set.getString(1);
173:                String wkt = set.getString(2);
174:                assertEquals("MGA94 Zone 52", name);
175:                assertTrue(wkt.indexOf("Geodetic Datum of Australia 1994") != -1);
176:
177:                //System.out.println( wkt );
178:                CoordinateReferenceSystem crs = CRS.parseWKT(wkt);
179:                //System.out.println( crs );
180:                assertNotNull(crs);
181:            }
182:
183:            public void testMetadataSRID() throws Exception {
184:                if (conn == null)
185:                    return;
186:
187:                Statement st = conn.createStatement();
188:                st
189:                        .execute("SELECT srid FROM USER_SDO_GEOM_METADATA where TABLE_NAME = 'ORA_TEST_LINES'");
190:                ResultSet set = st.getResultSet();
191:                assertTrue(set.next());
192:                int srid = set.getInt(1);
193:                assertEquals(82465, srid);
194:            }
195:
196:            public void testMetadataDIMInfo() throws Exception {
197:                if (conn == null)
198:                    return;
199:
200:                Statement st = conn.createStatement();
201:                st
202:                        .execute("SELECT srid,diminfo FROM USER_SDO_GEOM_METADATA where TABLE_NAME = 'ORA_TEST_LINES'");
203:                ResultSet set = st.getResultSet();
204:                assertTrue(set.next());
205:                int srid = set.getInt(1);
206:                CoordinateReferenceSystem crs = data.determineCRS(srid);
207:                ARRAY array = (ARRAY) set.getObject(2);
208:                Datum data[] = array.getOracleArray();
209:
210:                double minx = Double.NaN;
211:                double miny = Double.NaN;
212:                double maxx = Double.NaN;
213:                double maxy = Double.NaN;
214:
215:                for (int i = 0; i < data.length; i++) {
216:                    Datum datum = data[i];
217:                    System.out.println(datum.getClass());
218:                    STRUCT diminfo = (STRUCT) datum;
219:                    Datum info[] = diminfo.getOracleAttributes();
220:                    String ord = info[0].stringValue();
221:                    double min = info[1].doubleValue();
222:                    double max = info[2].doubleValue();
223:                    double precision = info[3].doubleValue(); // TODO use this for accurate JTS PercisionModel!
224:                    if ("X".equalsIgnoreCase(ord)) {
225:                        minx = min;
226:                        maxx = max;
227:                    }
228:                    if ("Y".equalsIgnoreCase(ord)) {
229:                        miny = min;
230:                        maxy = max;
231:                    }
232:                }
233:                Envelope extent = new Envelope(minx, maxx, miny, maxy);
234:                ReferencedEnvelope ref = new ReferencedEnvelope(extent, crs);
235:                assertFalse(ref.isNull());
236:            }
237:
238:            public void testDSSridMethod() throws Exception {
239:                if (conn == null)
240:                    return;
241:
242:                int srid = data.determineSRID("ORA_TEST_LINES", "SHAPE");
243:                assertEquals(82465, srid);
244:                CoordinateReferenceSystem crs = data.determineCRS(srid);
245:                assertNotNull(crs);
246:            }
247:
248:            public void testGeometryCRS() throws Exception {
249:                if (conn == null)
250:                    return;
251:                FeatureType schema = data.getSchema("ORA_TEST_LINES");
252:                GeometryAttributeType geom = schema.getDefaultGeometry();
253:
254:                assertNotNull(geom.getCoordinateSystem());
255:                assertEquals("SHAPE", geom.getName());
256:            }
257:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.