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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2007, 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:         *    This package contains documentation from OpenGIS specifications.
017:         *    OpenGIS consortium's work is fully acknowledged here.
018:         */
019:        package org.geotools.referencing.factory;
020:
021:        // JUnit dependencies
022:        import junit.framework.Test;
023:        import junit.framework.TestCase;
024:        import junit.framework.TestSuite;
025:
026:        // OpenGIS dependencies
027:        import org.opengis.referencing.crs.*;
028:        import org.opengis.referencing.datum.*;
029:        import org.opengis.referencing.IdentifiedObject;
030:        import org.opengis.referencing.FactoryException;
031:
032:        // Geotools dependencies
033:        import org.geotools.referencing.crs.*;
034:        import org.geotools.referencing.datum.*;
035:        import org.geotools.referencing.ReferencingFactoryFinder;
036:
037:        /**
038:         * Tests the {@link AuthorityFactoryProxy} implementation.
039:         *
040:         * @author Martin Desruisseaux
041:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/test/java/org/geotools/referencing/factory/AuthorityFactoryProxyTest.java $
042:         * @version $Id: AuthorityFactoryProxyTest.java 25396 2007-05-01 17:05:00Z desruisseaux $
043:         */
044:        public final class AuthorityFactoryProxyTest extends TestCase {
045:            /**
046:             * Run the suite from the command line.
047:             */
048:            public static void main(final String[] args) {
049:                junit.textui.TestRunner.run(suite());
050:            }
051:
052:            /**
053:             * Returns the test suite.
054:             */
055:            public static Test suite() {
056:                return new TestSuite(AuthorityFactoryProxyTest.class);
057:            }
058:
059:            /**
060:             * Creates a suite of the given name.
061:             */
062:            public AuthorityFactoryProxyTest(final String name) {
063:                super (name);
064:            }
065:
066:            /**
067:             * Tests {@link AuthorityFactoryProxy#getType(Class)}.
068:             */
069:            public void testType() {
070:                assertEquals(ProjectedCRS.class, AuthorityFactoryProxy
071:                        .getType(ProjectedCRS.class));
072:                assertEquals(ProjectedCRS.class, AuthorityFactoryProxy
073:                        .getType(DefaultProjectedCRS.class));
074:                assertEquals(GeographicCRS.class, AuthorityFactoryProxy
075:                        .getType(GeographicCRS.class));
076:                assertEquals(GeographicCRS.class, AuthorityFactoryProxy
077:                        .getType(DefaultGeographicCRS.class));
078:                assertEquals(DerivedCRS.class, AuthorityFactoryProxy
079:                        .getType(DefaultDerivedCRS.class));
080:                assertEquals(CoordinateReferenceSystem.class,
081:                        AuthorityFactoryProxy.getType(AbstractDerivedCRS.class));
082:                assertEquals(GeodeticDatum.class, AuthorityFactoryProxy
083:                        .getType(DefaultGeodeticDatum.class));
084:            }
085:
086:            /**
087:             * Tests {@link AuthorityFactoryProxy#create}. We uses the CRS factory for testing purpose.
088:             */
089:            public void testCreate() throws FactoryException {
090:                final CRSAuthorityFactory factory = ReferencingFactoryFinder
091:                        .getCRSAuthorityFactory("CRS", null);
092:                final CoordinateReferenceSystem expected = factory
093:                        .createCoordinateReferenceSystem("83");
094:                AuthorityFactoryProxy proxy;
095:                /*
096:                 * Try the proxy using the 'createGeographicCRS', 'createCoordinateReferenceSystem'
097:                 * and 'createObject' methods. The later uses a generic implementation, while the
098:                 * first two should use specialized implementations.
099:                 */
100:                proxy = AuthorityFactoryProxy.getInstance(factory,
101:                        GeographicCRS.class);
102:                assertTrue(proxy.getClass().getName().endsWith("Geographic"));
103:                assertSame(expected, proxy.create("83"));
104:                assertSame(expected, proxy.create("CRS:83"));
105:
106:                proxy = AuthorityFactoryProxy.getInstance(factory,
107:                        CoordinateReferenceSystem.class);
108:                assertTrue(proxy.getClass().getName().endsWith("CRS"));
109:                assertSame(expected, proxy.create("83"));
110:                assertSame(expected, proxy.create("CRS:83"));
111:
112:                proxy = AuthorityFactoryProxy.getInstance(factory,
113:                        IdentifiedObject.class);
114:                assertTrue(proxy.getClass().getName().endsWith("Default"));
115:                assertSame(expected, proxy.create("83"));
116:                assertSame(expected, proxy.create("CRS:83"));
117:                /*
118:                 * Try using the 'createProjectedCRS' method, which should not
119:                 * be supported for the CRS factory (at least not for code "83").
120:                 */
121:                proxy = AuthorityFactoryProxy.getInstance(factory,
122:                        ProjectedCRS.class);
123:                assertTrue(proxy.getClass().getName().endsWith("Projected"));
124:                try {
125:                    assertSame(expected, proxy.create("83"));
126:                    fail();
127:                } catch (FactoryException e) {
128:                    // This is the expected exception.
129:                    assertTrue(e.getCause() instanceof  ClassCastException);
130:                }
131:                /*
132:                 * Try using the 'createTemporalCRS' method, which should not
133:                 * be supported for the CRS factory (at least not for code "83").
134:                 * In addition, this code test the generic proxy instead of the
135:                 * specialized 'GeographicCRS' and 'ProjectedCRS' variants.
136:                 */
137:                proxy = AuthorityFactoryProxy.getInstance(factory,
138:                        TemporalCRS.class);
139:                assertTrue(proxy.getClass().getName().endsWith("Default"));
140:                try {
141:                    assertSame(expected, proxy.create("83"));
142:                    fail();
143:                } catch (FactoryException e) {
144:                    // This is the expected exception.
145:                    assertTrue(e.getCause() instanceof  ClassCastException);
146:                }
147:            }
148:
149:            /**
150:             * Tests {@link IdentifiedObjectFinder#createFromCodes}.
151:             * We uses the CRS factory for testing purpose.
152:             */
153:            public void testCreateFromCodes() throws FactoryException {
154:                final CRSAuthorityFactory factory = ReferencingFactoryFinder
155:                        .getCRSAuthorityFactory("CRS", null);
156:                final IdentifiedObjectFinder proxy = new IdentifiedObjectFinder(
157:                        factory, GeographicCRS.class);
158:                CoordinateReferenceSystem expected = factory
159:                        .createCoordinateReferenceSystem("84");
160:                assertNotSame(expected, DefaultGeographicCRS.WGS84);
161:                assertSame(expected, proxy.createFromCodes(expected));
162:                assertSame(expected, proxy.createFromIdentifiers(expected));
163:                assertNull(proxy.createFromNames(expected));
164:                assertSame(expected, proxy
165:                        .createFromCodes(DefaultGeographicCRS.WGS84));
166:                assertNull(proxy
167:                        .createFromIdentifiers(DefaultGeographicCRS.WGS84));
168:                assertNull(proxy.createFromNames(DefaultGeographicCRS.WGS84));
169:
170:                expected = factory.createCoordinateReferenceSystem("83");
171:                assertSame(expected, proxy.createFromCodes(expected));
172:                assertSame(expected, proxy.createFromIdentifiers(expected));
173:                assertNull(proxy.createFromNames(expected));
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.