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


001:        /*
002:         *    Geotools2 - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2005-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.data.complex;
018:
019:        import java.io.IOException;
020:        import java.net.URL;
021:        import java.util.Collections;
022:        import java.util.HashMap;
023:        import java.util.Map;
024:        import java.util.logging.Level;
025:
026:        import junit.framework.TestCase;
027:
028:        import org.geotools.data.DataAccess;
029:        import org.geotools.data.DataAccessFinder;
030:        import org.geotools.data.DataStoreFactorySpi;
031:        import org.geotools.data.feature.FeatureAccess;
032:        import org.geotools.data.feature.FeatureSource2;
033:        import org.geotools.feature.iso.Types;
034:        import org.geotools.util.logging.Logging;
035:        import org.opengis.feature.type.Name;
036:
037:        /**
038:         * 
039:         * @author Gabriel Roldan, Axios Engineering
040:         * @version $Id: ComplexDataStoreFactoryTest.java 27848 2007-11-12 13:10:32Z desruisseaux $
041:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/community-schemas/community-schema-ds/src/test/java/org/geotools/data/complex/ComplexDataStoreFactoryTest.java $
042:         * @since 2.4
043:         */
044:        public class ComplexDataStoreFactoryTest extends TestCase {
045:
046:            ComplexDataStoreFactory factory;
047:
048:            Map params;
049:
050:            private static final String NSURI = "http://online.socialchange.net.au";
051:
052:            static final Name mappedTypeName = Types.typeName(NSURI,
053:                    "RoadSegment");
054:
055:            protected void setUp() throws Exception {
056:                super .setUp();
057:                factory = new ComplexDataStoreFactory();
058:                params = new HashMap();
059:                params.put("dbtype", "complex");
060:                URL resource = getClass().getResource(
061:                        "/test-data/roadsegments.xml");
062:                if (resource == null) {
063:                    fail("Can't find resouce /test-data/roadsegments.xml");
064:                }
065:                params.put("url", resource);
066:            }
067:
068:            protected void tearDown() throws Exception {
069:                super .tearDown();
070:                factory = null;
071:                params = null;
072:            }
073:
074:            /**
075:             * Test method for
076:             * 'org.geotools.data.complex.ComplexDataStoreFactory.createDataStore(Map)'
077:             */
078:            public void testCreateDataStorePreconditions() {
079:                Map badParams = new HashMap();
080:                try {
081:                    factory.createDataStore(badParams);
082:                    fail("allowed bad params");
083:                } catch (IOException e) {
084:                    // OK
085:                }
086:                badParams.put("dbtype", "complex");
087:                try {
088:                    factory.createDataStore(badParams);
089:                    fail("allowed bad params");
090:                } catch (IOException e) {
091:                    // OK
092:                }
093:                badParams.put("url", "file://_inexistentConfigFile123456.xml");
094:                try {
095:                    factory.createDataStore(badParams);
096:                    fail("allowed bad params");
097:                } catch (IOException e) {
098:                    // OK
099:                }
100:            }
101:
102:            /*
103:             * public void test2()throws Exception{ String configFile =
104:             * "file:/home/gabriel/workspaces/complex_sco/GEOS/conf/data/featureTypes/complexWQ_Plus/wq_plus_mappings.xml";
105:             * Map params = new HashMap(); params.put("dbtype", "complex");
106:             * params.put("config", configFile);
107:             * 
108:             * DataStore ds = DataStoreFinder.getDataStore(params); assertNotNull(ds);
109:             * assertTrue(ds instanceof ComplexDataStore);
110:             * 
111:             * org.opengis.feature.type.FeatureType ft = ds.getSchema("wq_plus");
112:             * assertNotNull(ft);
113:             * 
114:             * FeatureSource fs = ds.getFeatureSource("wq_plus"); assertNotNull(fs);
115:             * FeatureIterator fi = fs.getFeatures().features(); while(fi.hasNext()){
116:             * Feature f = fi.next(); assertNotNull(f); Object result = XPath.get(f,
117:             * "measurement/result"); assertNotNull(result); } fi.close();
118:             * 
119:             * Envelope bounds = fs.getBounds(); assertNotNull(bounds); }
120:             */
121:
122:            /**
123:             * 
124:             * @throws IOException
125:             */
126:            public void testCreateDataStore() throws IOException {
127:                FeatureAccess ds = (FeatureAccess) factory
128:                        .createDataStore(params);
129:                assertNotNull(ds);
130:                FeatureSource2 mappedSource = (FeatureSource2) ds
131:                        .access(mappedTypeName);
132:                assertNotNull(mappedSource);
133:                assertSame(ds, mappedSource.getDataStore());
134:            }
135:
136:            /**
137:             * 
138:             * @throws IOException
139:             */
140:            public void testFactoryLookup() throws IOException {
141:                DataAccess ds = DataAccessFinder.createAccess(params);
142:                assertNotNull(ds);
143:                assertTrue(ds instanceof  ComplexDataStore);
144:
145:                FeatureSource2 mappedSource = (FeatureSource2) ds
146:                        .access(mappedTypeName);
147:                assertNotNull(mappedSource);
148:            }
149:
150:            /**
151:             * Test method for
152:             * 'org.geotools.data.complex.ComplexDataStoreFactory.createNewDataStore(Map)'
153:             */
154:            public void testCreateNewDataStore() throws IOException {
155:                try {
156:                    factory.createNewDataStore(Collections.EMPTY_MAP);
157:                    fail("unsupported?");
158:                } catch (UnsupportedOperationException e) {
159:                    // OK
160:                }
161:            }
162:
163:            /**
164:             * Test method for
165:             * 'org.geotools.data.complex.ComplexDataStoreFactory.getParametersInfo()'
166:             */
167:            public void testGetParametersInfo() {
168:                DataStoreFactorySpi.Param[] params = factory
169:                        .getParametersInfo();
170:                assertNotNull(params);
171:                assertEquals(2, params.length);
172:                assertEquals(String.class, params[0].type);
173:                assertEquals(URL.class, params[1].type);
174:            }
175:
176:            /**
177:             * 
178:             * Test method for
179:             * 'org.geotools.data.complex.ComplexDataStoreFactory.canProcess(Map)'
180:             */
181:            public void testCanProcess() {
182:                Map params = new HashMap();
183:                assertFalse(factory.canProcess(params));
184:                params.put("dbtype", "arcsde");
185:                params.put("url", "http://somesite.net/config.xml");
186:                assertFalse(factory.canProcess(params));
187:                params.remove("url");
188:                params.put("dbtype", "complex");
189:                assertFalse(factory.canProcess(params));
190:
191:                params.put("url", "http://somesite.net/config.xml");
192:                assertTrue(factory.canProcess(params));
193:            }
194:
195:            /**
196:             * 
197:             * Test method for
198:             * 'org.geotools.data.complex.ComplexDataStoreFactory.isAvailable()'
199:             */
200:            public void testIsAvailable() {
201:                assertTrue(factory.isAvailable());
202:            }
203:
204:            /**
205:             * 
206:             * Test method for
207:             * 'org.geotools.data.complex.ComplexDataStoreFactory.getImplementationHints()'
208:             */
209:            public void testGetImplementationHints() {
210:                assertNotNull(factory.getImplementationHints());
211:                assertEquals(0, factory.getImplementationHints().size());
212:            }
213:
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.