Source Code Cross Referenced for WMS1_1_1_OnlineTest.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » wms » test » 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.wms.test 
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; either
009:         *    version 2.1 of the License, or (at your option) any later version.
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.data.wms.test;
017:
018:        import java.io.IOException;
019:        import java.net.URISyntaxException;
020:        import java.net.URL;
021:        import java.util.Properties;
022:
023:        import org.geotools.data.ows.CRSEnvelope;
024:        import org.geotools.data.ows.Layer;
025:        import org.geotools.data.ows.Specification;
026:        import org.geotools.data.ows.StyleImpl;
027:        import org.geotools.data.ows.WMSCapabilities;
028:        import org.geotools.data.wms.WMS1_1_1;
029:        import org.geotools.data.wms.WebMapServer;
030:        import org.opengis.layer.Style;
031:        import org.xml.sax.SAXException;
032:
033:        /**
034:         * @author Richard Gould
035:         *
036:         * TODO To change the template for this generated type comment go to
037:         * Window - Preferences - Java - Code Style - Code Templates
038:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wms/src/test/java/org/geotools/data/wms/test/WMS1_1_1_OnlineTest.java $
039:         */
040:        public class WMS1_1_1_OnlineTest extends WMS1_1_0_OnlineTest {
041:
042:            public WMS1_1_1_OnlineTest() throws Exception {
043:                this .spec = new WMS1_1_1();
044:
045:                this .server = new URL(
046:                        "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?VERSION=1.1.0&REQUEST=GetCapabilities");
047:                this .getStylesURL = new URL(
048:                        "http://mapserv2.esrin.esa.it/cubestor/cubeserv/cubeserv.cgi?VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS");
049:            }
050:
051:            public void testGetVersion() {
052:                assertEquals(spec.getVersion(), "1.1.1");
053:            }
054:
055:            public void testCreateParser() throws Exception {
056:                try {
057:                    WMSCapabilities capabilities = createCapabilitiesViaStreamingParser("1.1.1Capabilities.xml");
058:
059:                    assertEquals(capabilities.getVersion(), "1.1.1");
060:                    assertEquals(capabilities.getService().getName(), "OGC:WMS");
061:                    assertEquals(capabilities.getService().getTitle(),
062:                            "Microsoft TerraServer Map Server");
063:                    assertEquals(
064:                            capabilities.getService().get_abstract(),
065:                            "WMT Map Server maintained by Microsoft Corporation.  Data returned provided by US Geological Survey.  Contact: tbarclay@microsoft.com or gylee@usgs.gov.");
066:                    assertEquals(capabilities.getService().getOnlineResource(),
067:                            new URL("http://terraservice.net/"));
068:
069:                    String[] keywords = { "USGS", "DOQ", "DRG", "Topographic",
070:                            "UrbanArea", "Urban Areas" };
071:
072:                    for (int i = 0; i < capabilities.getService()
073:                            .getKeywordList().length; i++) {
074:                        assertEquals(
075:                                capabilities.getService().getKeywordList()[i],
076:                                keywords[i]);
077:                    }
078:
079:                    assertEquals(capabilities.getService()
080:                            .getContactInformation().getIndividualName(),
081:                            "Some guy");
082:                    assertEquals(capabilities.getService()
083:                            .getContactInformation().getOrganisationName()
084:                            .toString(), "Some company");
085:                    assertEquals(capabilities.getService()
086:                            .getContactInformation().getPositionName()
087:                            .toString(), "Researcher");
088:                    assertTrue(capabilities.getService()
089:                            .getContactInformation().getContactInfo()
090:                            .getPhone().getVoices().contains("+1 555 555 5555"));
091:                    assertTrue(capabilities.getService()
092:                            .getContactInformation().getContactInfo()
093:                            .getPhone().getFacsimiles().contains(
094:                                    "+1 555 555 5556"));
095:                    assertEquals(capabilities.getService()
096:                            .getContactInformation().getContactInfo()
097:                            .getAddress().getPostalCode(), "11111");
098:                    assertEquals(capabilities.getService()
099:                            .getContactInformation().getContactInfo()
100:                            .getAddress().getAdministrativeArea().toString(),
101:                            "CA");
102:                    assertEquals(capabilities.getService()
103:                            .getContactInformation().getContactInfo()
104:                            .getAddress().getCity().toString(), "San Francisco");
105:                    assertEquals(capabilities.getService()
106:                            .getContactInformation().getContactInfo()
107:                            .getAddress().getCountry().toString(), "USA");
108:                    assertEquals(
109:                            capabilities.getService().getContactInformation()
110:                                    .getContactInfo().getAddress()
111:                                    .getDeliveryPoints().iterator().next(),
112:                            "555 Street St.");
113:                    assertEquals(capabilities.getService()
114:                            .getContactInformation().getContactInfo()
115:                            .getAddress().getElectronicMailAddresses()
116:                            .iterator().next(), "email@domain.com");
117:
118:                    assertEquals(capabilities.getRequest().getGetCapabilities()
119:                            .getFormats().get(0), "application/vnd.ogc.wms_xml");
120:                    assertEquals(capabilities.getRequest().getGetCapabilities()
121:                            .getGet(), new URL(
122:                            "http://terraservice.net/ogccapabilities.ashx"));
123:                    assertEquals(capabilities.getRequest().getGetCapabilities()
124:                            .getPost(), new URL(
125:                            "http://terraservice.net/ogccapabilities.ashx"));
126:
127:                    assertEquals(capabilities.getRequest().getGetMap()
128:                            .getFormats().get(0), "image/jpeg");
129:                    assertEquals(
130:                            capabilities.getRequest().getGetMap().getGet(),
131:                            new URL("http://terraservice.net/ogcmap.ashx"));
132:
133:                    assertNull(capabilities.getRequest().getGetFeatureInfo());
134:
135:                    assertEquals(capabilities.getLayerList().size(), 4);
136:
137:                    Layer layer = (Layer) capabilities.getLayerList().get(0);
138:                    assertNotNull(layer);
139:                    assertNull(layer.getName());
140:                    assertEquals(layer.getTitle(),
141:                            "Microsoft TerraServer Map Server");
142:                    assertEquals(layer.getSrs().size(), 1);
143:                    assertTrue(layer.getSrs().contains("EPSG:4326"));
144:
145:                    validateBoundingBox(layer.getLatLonBoundingBox(), -168.67,
146:                            17.84, -65.15, 71.55);
147:
148:                    assertNull(layer.getParent());
149:                    assertEquals(layer.getBoundingBoxes().size(), 0);
150:                    assertEquals(layer.getStyles().size(), 0);
151:
152:                    layer = (Layer) capabilities.getLayerList().get(1);
153:                    assertEquals(layer.getName(), "DOQ");
154:                    assertEquals(layer.getTitle(),
155:                            "USGS Digital Ortho-Quadrangles");
156:                    // changed expected to 14 to account for inherited srs
157:                    assertEquals(layer.getSrs().size(), 14);
158:                    // Added additional check to test for inherited srs
159:                    assertTrue(layer.getSrs().contains("EPSG:4326"));
160:                    assertTrue(layer.getSrs().contains("EPSG:26905"));
161:                    assertTrue(layer.getSrs().contains("EPSG:26920"));
162:                    assertEquals(layer.getBoundingBoxes().size(), 13);
163:                    CRSEnvelope bbox = (CRSEnvelope) layer.getBoundingBoxes()
164:                            .get("EPSG:26905");
165:                    assertNotNull(bbox);
166:                    assertEquals(bbox.getEPSGCode(), "EPSG:26905");
167:                    assertEquals(bbox.getMinX(), 552600.0, 0.0);
168:                    assertEquals(bbox.getMinY(), 6540200.0, 0.0);
169:                    assertEquals(bbox.getMaxX(), 670200.0, 0.0);
170:                    assertEquals(bbox.getMaxY(), 6794800.0, 0.0);
171:                    assertEquals(10, layer.getScaleHintMin(), 0);
172:                    assertEquals(10000, layer.getScaleHintMax(), 0);
173:
174:                    bbox = (CRSEnvelope) layer.getBoundingBoxes().get(
175:                            "EPSG:26920");
176:                    assertNotNull(bbox);
177:                    assertEquals(bbox.getEPSGCode(), "EPSG:26920");
178:                    assertEquals(bbox.getMinX(), 181800.0, 0.0);
179:                    assertEquals(bbox.getMinY(), 1985200.0, 0.0);
180:                    assertEquals(bbox.getMaxX(), 269400.0, 0.0);
181:                    assertEquals(bbox.getMaxY(), 2048600.0, 0.0);
182:
183:                    // Changed expected value, no duplicates allowed by spec
184:                    assertEquals(layer.getStyles().size(), 18);
185:                    assertTrue(layer.getStyles().contains(
186:                            new StyleImpl("UTMGrid")));
187:                    assertTrue(layer.getStyles().contains(
188:                            new StyleImpl("GeoGrid_Cyan")));
189:                    assertTrue(layer.getStyles().contains(
190:                            new StyleImpl("GeoGrid_Black")));
191:                    assertTrue(layer.getStyles().contains(
192:                            new StyleImpl("GeoGrid_Gray")));
193:                    assertTrue(layer.getStyles().contains(
194:                            new StyleImpl("GeoGrid_White")));
195:
196:                    Style utmGrid = (Style) layer.getStyles().get(0);
197:                    assertEquals(utmGrid.getName(), "UTMGrid");
198:                    assertEquals(utmGrid.getAbstract().toString(),
199:                            "Display grid lines in Goldenrod on the DOQ image");
200:                    assertEquals(utmGrid.getTitle().toString(),
201:                            "Goldedrod Grid Lines on UTM coordinates");
202:
203:                    assertFalse(layer.isQueryable());
204:
205:                    // Added test to verify inheritance, should be same as previous llbbox
206:                    validateBoundingBox(layer.getLatLonBoundingBox(), -168.67,
207:                            17.84, -65.15, 71.55);
208:
209:                    layer = (Layer) capabilities.getLayerList().get(2);
210:                    assertNotNull(layer);
211:                    assertEquals(layer.getName(), "DRG");
212:                    assertEquals(layer.getTitle(),
213:                            "USGS Raster Graphics (Topo Maps)");
214:                    // Added test to verify inheritance, should be same as previous llbbox
215:                    validateBoundingBox(layer.getLatLonBoundingBox(), -168.67,
216:                            17.84, -65.15, 71.55);
217:
218:                    assertEquals(50, layer.getScaleHintMin(), 0);
219:
220:                    layer = (Layer) capabilities.getLayerList().get(3);
221:                    assertNotNull(layer);
222:                    assertEquals(layer.getName(), "UrbanArea");
223:                    assertEquals(layer.getTitle(),
224:                            "USGS Urban Areas Ortho-Imagery");
225:                    // Added test to verify inheritance, should be same as previous llbbox
226:                    validateBoundingBox(layer.getLatLonBoundingBox(), -168.67,
227:                            17.84, -65.15, 71.55);
228:                    assertEquals(50000, layer.getScaleHintMax(), 0);
229:
230:                } catch (java.net.ConnectException ce) {
231:                    if (ce.getMessage().indexOf("timed out") > 0) {
232:                        System.err.println("Unable to test - timed out: " + ce);
233:                    } else {
234:                        throw (ce);
235:                    }
236:                }
237:            }
238:
239:            //Don't have working server to test against yet.
240:            //	public void testCreateGetStylesRequest() throws Exception {
241:            //      WebMapServer wms = new CustomWMS(getStylesURL);
242:            //
243:            //      GetStylesRequest request = wms.createGetStylesRequest();
244:            //      assertNotNull(request);
245:            //	}
246:
247:            /* (non-Javadoc)
248:             * @see org.geotools.data.wms.test.WMS1_0_0Test#checkProperties(java.util.Properties)
249:             */
250:            protected void checkProperties(Properties properties) {
251:                assertEquals(properties.get("VERSION"), "1.1.1");
252:                assertEquals(properties.get("REQUEST"), "GetCapabilities");
253:                assertEquals(properties.get("SERVICE"), "WMS");
254:            }
255:
256:            protected WebMapServer getCustomWMS(URL featureURL)
257:                    throws SAXException, URISyntaxException, IOException {
258:                return new CustomWMS(featureURL);
259:            }
260:
261:            //forces use of 1.1.1 spec
262:            private class CustomWMS extends WebMapServer {
263:
264:                /**
265:                 * @param serverURL
266:                 * @param wait
267:                 * @throws SAXException
268:                 * @throws URISyntaxException
269:                 * @throws IOException
270:                 */
271:                public CustomWMS(URL serverURL) throws SAXException,
272:                        URISyntaxException, IOException {
273:                    super (serverURL);
274:                    // TODO Auto-generated constructor stub
275:                }
276:
277:                protected void setupSpecifications() {
278:                    specs = new Specification[1];
279:                    specs[0] = new WMS1_1_1();
280:                }
281:            }
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.