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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) Copyright IBM Corporation, 2005. All rights reserved.
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.db2;
018:
019:        import org.geotools.data.DataStoreFactorySpi.Param;
020:        import java.io.IOException;
021:        import java.util.Map;
022:
023:        /**
024:         * Exercise DB2DataStoreFactory.
025:         *
026:         * @author David Adler - IBM Corporation
027:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/db2/src/test/java/org/geotools/data/db2/DB2DataStoreFactoryTest.java $
028:         */
029:        public class DB2DataStoreFactoryTest extends DB2TestCase {
030:            DB2DataStoreFactory factory = new DB2DataStoreFactory();
031:
032:            public void setUp() throws Exception {
033:                super .setUp();
034:            }
035:
036:            protected void tearDown() throws Exception {
037:                super .tearDown();
038:            }
039:
040:            public void testIsAvailable() {
041:                assertTrue("isAvailable didn't return true", factory
042:                        .isAvailable());
043:            }
044:
045:            public void testCreateDataStore() {
046:                // Should succeed
047:                try {
048:                    DB2DataStore dataStore = (DB2DataStore) factory
049:                            .createDataStore(allParams);
050:                } catch (IOException e) {
051:                    fail("createDataStore failed:" + e);
052:                }
053:
054:                // Should fail if dbtype is not "DB2"
055:                try {
056:                    Map params = copyParams(allParams);
057:                    params.put("dbtype", "nodb");
058:
059:                    DB2DataStore dataStore = (DB2DataStore) factory
060:                            .createDataStore(params);
061:                    fail("createDataStore succeeded with invalid dbtype parameter");
062:                } catch (IOException e) {
063:                    // We should come here as a result
064:                }
065:                // Should default schema to the user if schema is null
066:                try {
067:                    Map params = copyParams(allParams);
068:                    params.put("tabschema", null);
069:
070:                    DB2DataStore dataStore = (DB2DataStore) factory
071:                            .createDataStore(params);
072:                    String schema = dataStore.getTableSchema();
073:                    assertEquals("DB2ADMIN", schema);
074:                } catch (IOException e) {
075:                    fail("createDataStore failed:" + e);
076:                }
077:
078:                // Should default schema to the user if schema is blank
079:                try {
080:                    Map params = copyParams(allParams);
081:                    params.put("tabschema", "");
082:
083:                    DB2DataStore dataStore = (DB2DataStore) factory
084:                            .createDataStore(params);
085:                    String schema = dataStore.getTableSchema();
086:                    assertEquals("DB2ADMIN", schema);
087:                } catch (IOException e) {
088:                    fail("createDataStore failed:" + e);
089:                }
090:                // Should convert schema to uppercase
091:                try {
092:                    Map params = copyParams(allParams);
093:                    params.put("tabschema", "sde");
094:
095:                    DB2DataStore dataStore = (DB2DataStore) factory
096:                            .createDataStore(params);
097:                    String schema = dataStore.getTableSchema();
098:                    assertEquals("SDE", schema);
099:                } catch (IOException e) {
100:                    fail("createDataStore failed:" + e);
101:                }
102:                // Should leave schema in mixed case
103:                try {
104:                    Map params = copyParams(allParams);
105:                    params.put("tabschema", "\"Test\"");
106:
107:                    DB2DataStore dataStore = (DB2DataStore) factory
108:                            .createDataStore(params);
109:                    String schema = dataStore.getTableSchema();
110:                    assertEquals("Test", schema);
111:                } catch (IOException e) {
112:                    fail("createDataStore failed:" + e);
113:                }
114:            }
115:
116:            public void testCreateNewDataStore() {
117:                // Should fail
118:                try {
119:                    DB2DataStore dataStore = (DB2DataStore) factory
120:                            .createNewDataStore(allParams);
121:                    fail("createNewDataStore didn't fail");
122:                } catch (UnsupportedOperationException e) {
123:                    // We should come here as a result
124:                }
125:            }
126:
127:            public void testGetDescription() {
128:                assertEquals("DB2 Data Store", factory.getDescription());
129:            }
130:
131:            public void testGetDisplayName() {
132:                assertEquals("DB2", factory.getDisplayName());
133:            }
134:
135:            public void testGetParametersInfo() {
136:                Param[] params = factory.getParametersInfo();
137:                int i = 0;
138:
139:                try {
140:                    for (i = 0; i < params.length; i++) {
141:                        params[0].lookUp(allParams);
142:                    }
143:                } catch (IOException e) {
144:                    // should never get here
145:                    fail("lookUp failed on " + params[i]);
146:                }
147:
148:                // test for missing parameter
149:                Map paramMap = copyParams(allParams);
150:                paramMap.remove("dbtype");
151:
152:                try {
153:                    for (i = 0; i < params.length; i++) {
154:                        params[0].lookUp(paramMap);
155:                    }
156:
157:                    fail("Didn't fail on missing parameter dbtype");
158:                } catch (IOException e) {
159:                    // should get here in successful case
160:                }
161:            }
162:
163:            public void testCanProcess() {
164:                Map params;
165:
166:                // Make sure it succeeds for all good parameters
167:                params = copyParams(allParams);
168:                assertTrue("all parameters valid - should have succeeded",
169:                        factory.canProcess(params));
170:
171:                // Should fail if "database" parameter is missing
172:                params = copyParams(allParams);
173:                params.remove("database");
174:                assertFalse("database parameter is required", factory
175:                        .canProcess(params));
176:
177:                // Should fail if "dbtype" parameter is not "db2"
178:                params = copyParams(allParams);
179:                params.put("dbtype", "nodb");
180:                assertFalse("dbtype parameter is required", factory
181:                        .canProcess(params));
182:
183:                // Should succeed if "dbname" parameter is not lowercase
184:                params = copyParams(allParams);
185:                params.put("dbtype", "DB2");
186:                assertTrue("should succeed with uppercase DB2 as dbtype",
187:                        factory.canProcess(params));
188:
189:                // Should fail if "host" parameter is missing
190:                params = copyParams(allParams);
191:                params.remove("host");
192:                assertFalse("host parameter is required", factory
193:                        .canProcess(params));
194:
195:                // Should fail if "port" parameter is missing
196:                params = copyParams(allParams);
197:                params.remove("port");
198:                assertFalse("port parameter is required", factory
199:                        .canProcess(params));
200:
201:                // Should succeed if "user" parameter is missing - not sure if it should be mandatory
202:                params = copyParams(allParams);
203:                params.remove("user");
204:                assertTrue("user parameter should be optional", factory
205:                        .canProcess(params));
206:
207:                // Should succeed if "passwd" parameter is missing - not sure if it should be mandatory
208:                params = copyParams(allParams);
209:                params.remove("passwd");
210:                assertTrue("passwd parameter should be optional", factory
211:                        .canProcess(params));
212:
213:                // Should fail if "user" parameter is missing - not sure if it should be mandatory
214:                params = copyParams(allParams);
215:                params.remove("tabschema");
216:                assertTrue("tabschema parameter should be optional", factory
217:                        .canProcess(params));
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.