Source Code Cross Referenced for ComparableAxisWrapperTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » cs » 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.cs 
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:         *    (C) 2007, Geomatys
006:         *
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation;
010:         *    version 2.1 of the License.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.referencing.cs;
018:
019:        // J2SE dependencies and extensions
020:        import java.util.Arrays;
021:        import javax.units.SI;
022:
023:        // JUnit dependencies
024:        import junit.framework.Test;
025:        import junit.framework.TestCase;
026:        import junit.framework.TestSuite;
027:
028:        // OpenGIS dependencies
029:        import org.opengis.referencing.cs.AxisDirection;
030:        import org.opengis.referencing.cs.CoordinateSystemAxis;
031:
032:        /**
033:         * Tests the {@link ComparableAxisWrapper} class.
034:         *
035:         * @version $Id: ComparableAxisWrapperTest.java 24683 2007-03-06 06:02:15Z desruisseaux $
036:         * @author Martin Desruisseaux
037:         */
038:        public class ComparableAxisWrapperTest extends TestCase {
039:            /**
040:             * Run the suite from the command line.
041:             */
042:            public static void main(final String[] args) {
043:                junit.textui.TestRunner.run(suite());
044:            }
045:
046:            /**
047:             * Returns the test suite.
048:             */
049:            public static Test suite() {
050:                return new TestSuite(ComparableAxisWrapperTest.class);
051:            }
052:
053:            /**
054:             * Constructs a test case with the given name.
055:             */
056:            public ComparableAxisWrapperTest(final String name) {
057:                super (name);
058:            }
059:
060:            /**
061:             * Tests sorting of axis.
062:             */
063:            public void testSortAxis() {
064:                assertOrdered(
065:                        new CoordinateSystemAxis[] {
066:                                DefaultCoordinateSystemAxis.LONGITUDE,
067:                                DefaultCoordinateSystemAxis.LATITUDE,
068:                                DefaultCoordinateSystemAxis.ELLIPSOIDAL_HEIGHT },
069:                        new CoordinateSystemAxis[] {
070:                                DefaultCoordinateSystemAxis.LONGITUDE,
071:                                DefaultCoordinateSystemAxis.LATITUDE,
072:                                DefaultCoordinateSystemAxis.ELLIPSOIDAL_HEIGHT });
073:                assertOrdered(
074:                        new CoordinateSystemAxis[] {
075:                                DefaultCoordinateSystemAxis.LATITUDE,
076:                                DefaultCoordinateSystemAxis.ELLIPSOIDAL_HEIGHT,
077:                                DefaultCoordinateSystemAxis.LONGITUDE },
078:                        new CoordinateSystemAxis[] {
079:                                DefaultCoordinateSystemAxis.LONGITUDE,
080:                                DefaultCoordinateSystemAxis.LATITUDE,
081:                                DefaultCoordinateSystemAxis.ELLIPSOIDAL_HEIGHT });
082:            }
083:
084:            /**
085:             * Tests sorting of directions.
086:             */
087:            public void testSortDirections() {
088:                // A plausible CS.
089:                assertOrdered(new AxisDirection[] { AxisDirection.NORTH,
090:                        AxisDirection.UP, AxisDirection.EAST },
091:                        new AxisDirection[] { AxisDirection.EAST, // Right handed-rule
092:                                AxisDirection.NORTH, // Right handed-rule
093:                                AxisDirection.UP });
094:
095:                // A very dummy CS just for testing. The order of
096:                // any non-compass direction should be unchanged.
097:                assertOrdered(new AxisDirection[] { AxisDirection.GEOCENTRIC_Y,
098:                        AxisDirection.NORTH_NORTH_WEST,
099:                        AxisDirection.GEOCENTRIC_X, AxisDirection.NORTH_EAST,
100:                        AxisDirection.PAST }, new AxisDirection[] {
101:                        AxisDirection.NORTH_EAST, // Right handed-rule
102:                        AxisDirection.NORTH_NORTH_WEST, // Right handed-rule
103:                        AxisDirection.GEOCENTRIC_Y, AxisDirection.GEOCENTRIC_X,
104:                        AxisDirection.PAST });
105:
106:                // An other plausible CS.
107:                assertOrdered(new AxisDirection[] { AxisDirection.SOUTH,
108:                        AxisDirection.DOWN, AxisDirection.WEST },
109:                        new AxisDirection[] { AxisDirection.WEST, // Right handed-rule
110:                                AxisDirection.SOUTH, // Right handed-rule
111:                                AxisDirection.DOWN });
112:
113:                // An other plausible CS.
114:                assertOrdered(new AxisDirection[] { AxisDirection.SOUTH,
115:                        AxisDirection.DOWN, AxisDirection.EAST },
116:                        new AxisDirection[] { AxisDirection.SOUTH, // Right handed-rule
117:                                AxisDirection.EAST, // Right handed-rule
118:                                AxisDirection.DOWN });
119:            }
120:
121:            /**
122:             * Sorts the specified axis and compares against the expected result.
123:             */
124:            private static void assertOrdered(
125:                    final CoordinateSystemAxis[] toTest,
126:                    final CoordinateSystemAxis[] expected) {
127:                final boolean same = Arrays.equals(toTest, expected);
128:                assertEquals(!same, ComparableAxisWrapper.sort(toTest));
129:                assertTrue(Arrays.equals(toTest, expected));
130:            }
131:
132:            /**
133:             * Sorts the specified directions and compares against the expected result.
134:             */
135:            private static void assertOrdered(final AxisDirection[] toTest,
136:                    final AxisDirection[] expected) {
137:                assertOrdered(toAxis(toTest), toAxis(expected));
138:            }
139:
140:            /**
141:             * Creates axis from the specified directions.
142:             */
143:            private static CoordinateSystemAxis[] toAxis(
144:                    final AxisDirection[] directions) {
145:                final CoordinateSystemAxis[] axis = new CoordinateSystemAxis[directions.length];
146:                for (int i = 0; i < directions.length; i++) {
147:                    axis[i] = new DefaultCoordinateSystemAxis("Test",
148:                            directions[i], SI.METER);
149:                }
150:                return axis;
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.