Source Code Cross Referenced for ArcSDEQueryTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » arcsde » data » 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.arcsde.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    Geotools2 - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-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;
009:         *    version 2.1 of the License.
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:         */
017:        package org.geotools.arcsde.data;
018:
019:        import java.io.IOException;
020:        import java.util.ArrayList;
021:        import java.util.HashSet;
022:        import java.util.List;
023:
024:        import junit.framework.TestCase;
025:
026:        import org.geotools.data.DefaultQuery;
027:        import org.geotools.data.FeatureReader;
028:        import org.geotools.data.Query;
029:        import org.geotools.factory.CommonFactoryFinder;
030:        import org.geotools.feature.FeatureType;
031:        import org.opengis.filter.FilterFactory;
032:        import org.opengis.filter.Id;
033:
034:        import com.esri.sde.sdk.client.SeConnection;
035:        import com.vividsolutions.jts.geom.Envelope;
036:
037:        /**
038:         * DOCUMENT ME!
039:         *
040:         * @author Gabriel Roldan
041:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/arcsde/datastore/src/test/java/org/geotools/arcsde/data/ArcSDEQueryTest.java $
042:         * @version $Revision: 1.9 $
043:         */
044:        public class ArcSDEQueryTest extends TestCase {
045:
046:            private TestData testData;
047:
048:            /**
049:             * do not access it directly, use {@link #getQueryAll()}
050:             */
051:            private ArcSDEQuery queryAll;
052:
053:            /**
054:             * do not access it directly, use {@link #getQueryFiltered()}
055:             */
056:            private ArcSDEQuery queryFiltered;
057:
058:            private ArcSDEDataStore dstore;
059:
060:            private String typeName;
061:
062:            private Query filteringQuery;
063:
064:            private FilterFactory ff = CommonFactoryFinder
065:                    .getFilterFactory(null);
066:
067:            private FeatureType ftype;
068:
069:            private static final int FILTERING_COUNT = 3;
070:
071:            /**
072:             * Constructor for ArcSDEQueryTest.
073:             *
074:             * @param arg0
075:             */
076:            public ArcSDEQueryTest(String name) {
077:                super (name);
078:            }
079:
080:            /**
081:             * loads {@code test-data/testparams.properties} into a Properties object, wich is
082:             * used to obtain test tables names and is used as parameter to find the DataStore
083:             *
084:             * @throws Exception DOCUMENT ME!
085:             */
086:            protected void setUp() throws Exception {
087:                super .setUp();
088:                this .testData = new TestData();
089:                this .testData.setUp();
090:                dstore = testData.getDataStore();
091:                typeName = testData.getLine_table();
092:                this .ftype = dstore.getSchema(typeName);
093:
094:                //grab some fids
095:                FeatureReader reader = dstore.getFeatureReader(typeName);
096:                List fids = new ArrayList();
097:                for (int i = 0; i < FILTERING_COUNT; i++) {
098:                    fids.add(ff.featureId(reader.next().getID()));
099:                }
100:                reader.close();
101:                Id filter = ff.id(new HashSet(fids));
102:                filteringQuery = new DefaultQuery(typeName, filter);
103:            }
104:
105:            private ArcSDEQuery getQueryAll() throws IOException {
106:                this .queryAll = ArcSDEQuery.createQuery(dstore, ftype,
107:                        Query.ALL);
108:                return this .queryAll;
109:            }
110:
111:            private ArcSDEQuery getQueryFiltered() throws IOException {
112:                this .queryFiltered = ArcSDEQuery.createQuery(dstore,
113:                        filteringQuery);
114:                return this .queryFiltered;
115:            }
116:
117:            /**
118:             * DOCUMENT ME!
119:             *
120:             * @throws Exception DOCUMENT ME!
121:             */
122:            protected void tearDown() throws Exception {
123:                super .tearDown();
124:                try {
125:                    this .queryAll.close();
126:                } catch (Exception e) {
127:                    //no-op
128:                }
129:                try {
130:                    this .queryFiltered.close();
131:                } catch (Exception e) {
132:                    //no-op
133:                }
134:                this .queryAll = null;
135:                this .queryFiltered = null;
136:                testData.tearDown(true, true);
137:                testData = null;
138:            }
139:
140:            /**
141:             * DOCUMENT ME!
142:             */
143:            public void testClose() throws IOException {
144:                ArcSDEQuery queryAll = getQueryAll();
145:                assertNotNull(queryAll.connection);
146:
147:                queryAll.execute();
148:
149:                assertNotNull(queryAll.connection);
150:
151:                //should nevel do this, just to assert it is 
152:                //not closed by returned to the pool
153:                SeConnection conn = queryAll.connection;
154:
155:                queryAll.close();
156:
157:                assertNull(queryAll.connection);
158:                assertFalse(conn.isClosed());
159:            }
160:
161:            /**
162:             * DOCUMENT ME!
163:             */
164:            public void testFetch() throws IOException {
165:                ArcSDEQuery queryAll = getQueryAll();
166:                try {
167:                    queryAll.fetch();
168:                    fail("fetch without calling execute");
169:                } catch (IllegalStateException e) {
170:                    //ok
171:                }
172:
173:                queryAll.execute();
174:                assertNotNull(queryAll.fetch());
175:
176:                queryAll.close();
177:                try {
178:                    queryAll.fetch();
179:                    fail("fetch after close!");
180:                } catch (IllegalStateException e) {
181:                    //ok
182:                }
183:            }
184:
185:            /**
186:             * DOCUMENT ME!
187:             */
188:            public void testCalculateResultCount() throws Exception {
189:                FeatureReader reader = dstore.getFeatureReader(typeName);
190:                int readed = 0;
191:                while (reader.hasNext()) {
192:                    reader.next();
193:                    readed++;
194:                }
195:
196:                int calculated = getQueryAll().calculateResultCount();
197:                assertEquals(readed, calculated);
198:
199:                calculated = getQueryFiltered().calculateResultCount();
200:                assertEquals(FILTERING_COUNT, calculated);
201:            }
202:
203:            /**
204:             * DOCUMENT ME!
205:             */
206:            public void testCalculateQueryExtent() throws Exception {
207:                FeatureReader reader = dstore.getFeatureReader(typeName);
208:                Envelope real = new Envelope();
209:                while (reader.hasNext()) {
210:                    real.expandToInclude(reader.next().getBounds());
211:                }
212:
213:                Envelope e = getQueryAll().calculateQueryExtent();
214:                assertNotNull(e);
215:                assertEquals(real, e);
216:
217:                reader.close();
218:
219:                reader = dstore.getFeatureReader(typeName, filteringQuery);
220:                real = new Envelope();
221:                while (reader.hasNext()) {
222:                    real.expandToInclude(reader.next().getBounds());
223:                }
224:
225:                e = getQueryFiltered().calculateQueryExtent();
226:                assertNotNull(e);
227:                assertEquals(real, e);
228:                reader.close();
229:            }
230:
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.