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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-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:        package org.geotools.referencing.factory.epsg;
017:
018:        // JSE dependencies
019:        import java.util.Set;
020:        import java.util.Iterator;
021:        import java.io.PrintWriter;
022:        import java.io.StringWriter;
023:
024:        // OpenGIS dependencies
025:        import org.opengis.metadata.Identifier;
026:        import org.opengis.metadata.citation.Citation;
027:        import org.opengis.referencing.IdentifiedObject;
028:        import org.opengis.referencing.FactoryException;
029:        import org.opengis.referencing.NoSuchAuthorityCodeException;
030:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
031:
032:        // Geotools dependencies
033:        import org.geotools.referencing.ReferencingFactoryFinder;
034:        import org.geotools.referencing.NamedIdentifier;
035:        import org.geotools.metadata.iso.citation.Citations;
036:
037:        // JUnit dependencies
038:        import junit.framework.Test;
039:        import junit.framework.TestCase;
040:        import junit.framework.TestSuite;
041:
042:        /**
043:         * Tests ESRI CRS support.
044:         * 
045:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/epsg-extension/src/test/java/org/geotools/referencing/factory/epsg/EsriExtensionTest.java $
046:         * @version $Id: EsriExtensionTest.java 25398 2007-05-02 13:32:07Z desruisseaux $
047:         * @author Jody Garnett
048:         * @author Martin Desruisseaux
049:         */
050:        public class EsriExtensionTest extends TestCase {
051:            /**
052:             * The factory to test.
053:             */
054:            private EsriExtension factory;
055:
056:            /**
057:             * Returns the test suite.
058:             */
059:            public static Test suite() {
060:                return new TestSuite(EsriExtensionTest.class);
061:            }
062:
063:            /**
064:             * Run the test from the command line.
065:             * Options: {@code -verbose}.
066:             *
067:             * @param args the command line arguments.
068:             */
069:            public static void main(final String[] args) {
070:                junit.textui.TestRunner.run(suite());
071:            }
072:
073:            /**
074:             * Creates a test case with the specified name.
075:             */
076:            public EsriExtensionTest(final String name) {
077:                super (name);
078:            }
079:
080:            /**
081:             * Get the authority factory for ESRI.
082:             */
083:            protected void setUp() throws Exception {
084:                super .setUp();
085:                factory = (EsriExtension) ReferencingFactoryFinder
086:                        .getCRSAuthorityFactory("ESRI", null);
087:            }
088:
089:            /**
090:             * Tests the authority code.
091:             */
092:            public void testAuthority() {
093:                Citation authority = factory.getAuthority();
094:                assertNotNull(authority);
095:                assertEquals("ESRI", authority.getTitle().toString());
096:                assertTrue(factory instanceof  EsriExtension);
097:            }
098:
099:            /**
100:             * Tests the vendor.
101:             */
102:            public void testVendor() {
103:                Citation vendor = factory.getVendor();
104:                assertNotNull(vendor);
105:                assertEquals("Geotools", vendor.getTitle().toString());
106:            }
107:
108:            /**
109:             * Tests the codes.
110:             */
111:            public void testCodes() throws FactoryException {
112:                final Set codes = factory
113:                        .getAuthorityCodes(IdentifiedObject.class);
114:                final Set subset = factory
115:                        .getAuthorityCodes(CoordinateReferenceSystem.class);
116:                assertNotNull(codes);
117:                assertEquals(codes.size(), subset.size());
118:                assertTrue(codes.containsAll(subset));
119:                assertFalse(codes.contains("26910")); // This is an EPSG code.
120:                // The following number may be adjusted if esri.properties is updated.
121:                assertEquals(779, codes.size());
122:            }
123:
124:            /**
125:             * Checks for duplication with EPSG-HSQL.
126:             */
127:            public void testDuplication() throws FactoryException {
128:                final StringWriter buffer = new StringWriter();
129:                final PrintWriter writer = new PrintWriter(buffer);
130:                final Set duplicated = factory.reportDuplicatedCodes(writer);
131:                assertTrue(buffer.toString(), duplicated.isEmpty());
132:            }
133:
134:            /**
135:             * Checks for CRS instantiations.
136:             */
137:            public void testInstantiation() throws FactoryException {
138:                final StringWriter buffer = new StringWriter();
139:                final PrintWriter writer = new PrintWriter(buffer);
140:                final Set duplicated = factory
141:                        .reportInstantiationFailures(writer);
142:                // The following number may be adjusted if esri.properties is updated.
143:                assertTrue(buffer.toString(), duplicated.size() <= 87);
144:            }
145:
146:            /**
147:             * Tests an EPSG code.
148:             */
149:            public void test26910() throws FactoryException {
150:                try {
151:                    CoordinateReferenceSystem crs = factory
152:                            .createCoordinateReferenceSystem("26910");
153:                    fail();
154:                } catch (NoSuchAuthorityCodeException e) {
155:                    // This is the expected exception.
156:                }
157:            }
158:
159:            /**
160:             * Tests an EPSG code.
161:             */
162:            public void test4326() throws FactoryException {
163:                try {
164:                    CoordinateReferenceSystem crs = factory
165:                            .createCoordinateReferenceSystem("4326");
166:                    fail();
167:                } catch (NoSuchAuthorityCodeException e) {
168:                    // This is the expected exception.
169:                }
170:            }
171:
172:            /**
173:             * Tests an EPSG code.
174:             */
175:            public void test4269() throws FactoryException {
176:                try {
177:                    CoordinateReferenceSystem crs = factory
178:                            .createCoordinateReferenceSystem("4269");
179:                    fail();
180:                } catch (NoSuchAuthorityCodeException e) {
181:                    // This is the expected exception.
182:                }
183:            }
184:
185:            /**
186:             * Tests an extra code (neither EPSG or ESRI).
187:             */
188:            public void test42102() throws FactoryException {
189:                try {
190:                    CoordinateReferenceSystem crs = factory
191:                            .createCoordinateReferenceSystem("42102");
192:                    fail();
193:                } catch (NoSuchAuthorityCodeException e) {
194:                    // This is the expected exception.
195:                }
196:            }
197:
198:            /**
199:             * Tests an ESRI code.
200:             */
201:            public void test30591() throws FactoryException {
202:                final CoordinateReferenceSystem crs = factory
203:                        .createCoordinateReferenceSystem("30591");
204:                assertSame(crs, factory
205:                        .createCoordinateReferenceSystem("ESRI:30591"));
206:                assertSame(crs, factory
207:                        .createCoordinateReferenceSystem("esri:30591"));
208:                assertSame(crs, factory
209:                        .createCoordinateReferenceSystem(" ESRI : 30591 "));
210:                assertSame(crs, factory
211:                        .createCoordinateReferenceSystem("EPSG:30591"));
212:                assertSame(crs, factory.createObject("30591"));
213:                final Set identifiers = crs.getIdentifiers();
214:                assertNotNull(identifiers);
215:                assertFalse(identifiers.isEmpty());
216:
217:                String asString = identifiers.toString();
218:                assertTrue(asString, identifiers.contains(new NamedIdentifier(
219:                        Citations.ESRI, "30591")));
220:                assertTrue(asString, identifiers.contains(new NamedIdentifier(
221:                        Citations.EPSG, "30591")));
222:
223:                final Iterator iterator = identifiers.iterator();
224:                Identifier identifier;
225:
226:                // Checks the first identifier.
227:                assertTrue(iterator.hasNext());
228:                identifier = (Identifier) iterator.next();
229:                assertTrue(identifier instanceof  NamedIdentifier);
230:                assertEquals(Citations.ESRI, identifier.getAuthority());
231:                assertEquals("30591", identifier.getCode());
232:                assertEquals("ESRI:30591", identifier.toString());
233:
234:                // Checks the second identifier.
235:                assertTrue(iterator.hasNext());
236:                identifier = (Identifier) iterator.next();
237:                assertTrue(identifier instanceof  NamedIdentifier);
238:                assertEquals(Citations.EPSG, identifier.getAuthority());
239:                assertEquals("30591", identifier.getCode());
240:                assertEquals("EPSG:30591", identifier.toString());
241:            }
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.