Source Code Cross Referenced for IdentifiedObjectTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » referencing » 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 
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:         *    (C) 2004, Institut de Recherche pour le Développement
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; either
010:         *    version 2.1 of the License, or (at your option) any later version.
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;
018:
019:        // J2SE dependencies
020:        import java.util.HashMap;
021:        import java.util.Locale;
022:        import java.util.Map;
023:
024:        // JUnit dependencies
025:        import junit.framework.Test;
026:        import junit.framework.TestCase;
027:        import junit.framework.TestSuite;
028:
029:        // OpenGIS dependencies
030:        import org.opengis.parameter.InvalidParameterValueException;
031:        import org.opengis.util.InternationalString;
032:
033:        // Geotools dependencies
034:        import org.geotools.metadata.iso.citation.CitationImpl;
035:        import org.geotools.util.SimpleInternationalString;
036:
037:        /**
038:         * Tests the creation of {@link AbstractIdentifiedObject} and a few subclasses.
039:         *
040:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/referencing/src/test/java/org/geotools/referencing/IdentifiedObjectTest.java $
041:         * @version $Id: IdentifiedObjectTest.java 27848 2007-11-12 13:10:32Z desruisseaux $
042:         * @author Martin Desruisseaux
043:         */
044:        public final class IdentifiedObjectTest extends TestCase {
045:            /**
046:             * Run the suite from the command line.
047:             */
048:            public static void main(String[] args) {
049:                org.geotools.util.logging.Logging.GEOTOOLS
050:                        .forceMonolineConsoleOutput();
051:                junit.textui.TestRunner.run(suite());
052:            }
053:
054:            /**
055:             * Returns the test suite.
056:             */
057:            public static Test suite() {
058:                return new TestSuite(IdentifiedObjectTest.class);
059:            }
060:
061:            /**
062:             * Construct a test case.
063:             */
064:            public IdentifiedObjectTest(String testName) {
065:                super (testName);
066:            }
067:
068:            /**
069:             * Tests {@link NamedIdentifier} attributes. Useful for making sure that the
070:             * hash code enumerated in the switch statement in the constructor have
071:             * the correct value.
072:             */
073:            public void testIdentifier() {
074:                final Map properties = new HashMap();
075:                assertNull(properties.put("code", "This is a code"));
076:                assertNull(properties.put("authority", "This is an authority"));
077:                assertNull(properties.put("version", "This is a version"));
078:                assertNull(properties.put("dummy", "Doesn't matter"));
079:                assertNull(properties.put("remarks", "There is remarks"));
080:                assertNull(properties.put("remarks_fr", "Voici des remarques"));
081:                assertNull(properties.put("remarks_fr_CA", "Pareil"));
082:
083:                NamedIdentifier identifier = new NamedIdentifier(properties);
084:                assertEquals("code", "This is a code", identifier.getCode());
085:                assertEquals("authority", "This is an authority", identifier
086:                        .getAuthority().getTitle().toString());
087:                assertEquals("version", "This is a version", identifier
088:                        .getVersion());
089:                assertEquals("remarks", "There is remarks", identifier
090:                        .getRemarks().toString(Locale.ENGLISH));
091:                assertEquals("remarks_fr", "Voici des remarques", identifier
092:                        .getRemarks().toString(Locale.FRENCH));
093:                assertEquals("remarks_fr_CA", "Pareil", identifier.getRemarks()
094:                        .toString(Locale.CANADA_FRENCH));
095:                assertEquals("remarks_fr_BE", "Voici des remarques", identifier
096:                        .getRemarks().toString(new Locale("fr", "BE")));
097:
098:                if (false) {
099:                    // Disabled in order to avoid logging a warning (it disturb the JUnit output)
100:                    properties.put("remarks", new SimpleInternationalString(
101:                            "Overrides remarks"));
102:                    identifier = new NamedIdentifier(properties);
103:                    assertEquals("remarks", "Overrides remarks", identifier
104:                            .getRemarks().toString(Locale.ENGLISH));
105:                }
106:
107:                assertNotNull(properties.remove("authority"));
108:                assertNull(properties.put("AutHOrITY", new CitationImpl(
109:                        "An other authority")));
110:                identifier = new NamedIdentifier(properties);
111:                assertEquals("authority", "An other authority", identifier
112:                        .getAuthority().getTitle().toString(Locale.ENGLISH));
113:
114:                assertNotNull(properties.remove("AutHOrITY"));
115:                assertNull(properties.put("authority", Locale.CANADA));
116:                try {
117:                    identifier = new NamedIdentifier(properties);
118:                    fail();
119:                } catch (InvalidParameterValueException exception) {
120:                    // This is the expected exception
121:                }
122:            }
123:
124:            /**
125:             * Test {@link IdentifiedObject}.
126:             */
127:            public void testIdentifiedObject() {
128:                final Map properties = new HashMap();
129:                assertNull(properties.put("name", "This is a name"));
130:                assertNull(properties.put("remarks", "There is remarks"));
131:                assertNull(properties.put("remarks_fr", "Voici des remarques"));
132:                assertNull(properties.put("dummy", "Doesn't matter"));
133:                assertNull(properties.put("dummy_fr", "Rien d'intéressant"));
134:                assertNull(properties.put("local", "A custom localized string"));
135:                assertNull(properties
136:                        .put("local_fr", "Une chaîne personalisée"));
137:                assertNull(properties.put("anchorPoint", "Anchor point"));
138:                assertNull(properties.put("realizationEpoch",
139:                        "Realization epoch"));
140:                assertNull(properties.put("validArea", "Valid area"));
141:
142:                final Map remaining = new HashMap();
143:                final AbstractIdentifiedObject reference = new AbstractIdentifiedObject(
144:                        properties, remaining, new String[] { "local" });
145:                assertEquals("name", "This is a name", reference.getName()
146:                        .getCode());
147:                assertEquals("remarks", "There is remarks", reference
148:                        .getRemarks().toString(null));
149:                assertEquals("remarks_fr", "Voici des remarques", reference
150:                        .getRemarks().toString(Locale.FRENCH));
151:
152:                // Check extra properties
153:                assertEquals("Size:", 6, remaining.size());
154:                assertEquals("dummy", "Doesn't matter", remaining.get("dummy"));
155:                assertEquals("dummy_fr", "Rien d'intéressant", remaining
156:                        .get("dummy_fr"));
157:                assertEquals("local", "A custom localized string",
158:                        ((InternationalString) remaining.get("local"))
159:                                .toString(null));
160:                assertEquals("local_fr", "Une chaîne personalisée",
161:                        ((InternationalString) remaining.get("local"))
162:                                .toString(Locale.FRENCH));
163:                assertFalse("local_fr", remaining.containsKey("local_fr"));
164:
165:                // Check the case of some special property keys
166:                assertEquals("anchorPoint", "Anchor point", remaining
167:                        .get("anchorPoint"));
168:                assertEquals("realizationEpoch", "Realization epoch", remaining
169:                        .get("realizationEpoch"));
170:                assertEquals("validArea", "Valid area", remaining
171:                        .get("validArea"));
172:            }
173:
174:            /**
175:             * Test {@link AbstractReferenceSystem}.
176:             */
177:            public void testReferenceSystem() {
178:                final Map properties = new HashMap();
179:                assertNull(properties.put("name", "This is a name"));
180:                assertNull(properties.put("scope", "This is a scope"));
181:                assertNull(properties.put("scope_fr", "Valide dans ce domaine"));
182:                assertNull(properties.put("remarks", "There is remarks"));
183:                assertNull(properties.put("remarks_fr", "Voici des remarques"));
184:
185:                final AbstractReferenceSystem reference = new AbstractReferenceSystem(
186:                        properties);
187:                assertEquals("name", "This is a name", reference.getName()
188:                        .getCode());
189:                assertEquals("scope", "This is a scope", reference.getScope()
190:                        .toString(null));
191:                assertEquals("scope_fr", "Valide dans ce domaine", reference
192:                        .getScope().toString(Locale.FRENCH));
193:                assertEquals("remarks", "There is remarks", reference
194:                        .getRemarks().toString(null));
195:                assertEquals("remarks_fr", "Voici des remarques", reference
196:                        .getRemarks().toString(Locale.FRENCH));
197:            }
198:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.