Source Code Cross Referenced for WMS1_1_0_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.WMSCapabilities;
027:        import org.geotools.data.wms.WMS1_1_0;
028:        import org.geotools.data.wms.WebMapServer;
029:        import org.geotools.data.wms.request.GetMapRequest;
030:        import org.xml.sax.SAXException;
031:
032:        /**
033:         * @author Richard Gould
034:         *
035:         * TODO To change the template for this generated type comment go to
036:         * Window - Preferences - Java - Code Style - Code Templates
037:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wms/src/test/java/org/geotools/data/wms/test/WMS1_1_0_OnlineTest.java $
038:         */
039:        public class WMS1_1_0_OnlineTest extends WMS1_0_0_OnlineTest {
040:            protected URL getStylesURL;
041:
042:            public WMS1_1_0_OnlineTest() throws Exception {
043:                server = new URL(
044:                        "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap?VERSION=1.1.0&REQUEST=GetCapabilities");
045:                spec = new WMS1_1_0();
046:            }
047:
048:            public void testGetVersion() {
049:                assertEquals(spec.getVersion(), "1.1.0");
050:            }
051:
052:            /* (non-Javadoc)
053:             * @see org.geotools.data.wms.test.WMS1_0_0Test#checkProperties(java.util.Properties)
054:             */
055:            protected void checkProperties(Properties properties) {
056:                assertEquals(properties.get("REQUEST"), "GetCapabilities");
057:                assertEquals(properties.get("VERSION"), "1.1.0");
058:                assertEquals(properties.get("SERVICE"), "WMS");
059:            }
060:
061:            public void testCreateDescribeLayerRequest() throws Exception {
062:                /* TODO FIX
063:                 try{
064:                 WebMapServer wms = new CustomWMS(server);
065:                 DescribeLayerRequest request = wms.createDescribeLayerRequest();
066:                 assertNotNull(request);
067:                 request.setLayers("land_fn,park,drain_fn,road,popplace");
068:                 System.out.println(request.getFinalURL());
069:                 DescribeLayerResponse response = (DescribeLayerResponse) wms.issueRequest(request);
070:                 assertNotNull(response);
071:                
072:                 LayerDescription[] layerDescs = response.getLayerDescs();
073:                 assertEquals(layerDescs.length, 5);
074:                
075:                 assertEquals(layerDescs[0].getName(), "land_fn");
076:                 assertEquals(layerDescs[1].getName(), "park");
077:                 assertEquals(layerDescs[2].getName(), "drain_fn");
078:                 assertEquals(layerDescs[3].getName(), "road");
079:                 assertEquals(layerDescs[4].getName(), "popplace");
080:                
081:                 assertEquals(layerDescs[1].getWfs(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswfs_gmap?"));
082:                 assertEquals(layerDescs[4].getWfs(), new URL("http://dev1.dmsolutions.ca/cgi-bin/mswfs_gmap?"));
083:                
084:                 assertEquals(layerDescs[1].getQueries().length, 1);
085:                 assertEquals(layerDescs[4].getQueries().length, 1);
086:                
087:                 assertEquals(layerDescs[1].getQueries()[0], "park");
088:                 assertEquals(layerDescs[4].getQueries()[0], "popplace");
089:                 } catch(java.net.ConnectException ce){
090:                 if(ce.getMessage().indexOf("timed out")>0){
091:                 System.err.println("Unable to test - timed out: "+ce);
092:                 } else{
093:                 throw(ce);
094:                 }
095:                 }
096:                 */
097:            }
098:
099:            public void testCreateGetLegendGraphicRequest() throws Exception {
100:                /* TODO FIX
101:                try{
102:                    
103:                    WebMapServer wms = new CustomWMS(server);
104:                    GetLegendGraphicRequest request = wms.createGetLegendGraphicRequest();
105:                    
106:                    assertNotNull(request);
107:                    
108:                    Layer[] layers = WMSUtils.getNamedLayers(wms.getCapabilities());
109:                    SimpleLayer park = null;
110:                    for (int i = 0; i < layers.length; i++) {
111:                        if (layers[i].getName().equals("park")) {
112:                            park = new SimpleLayer(layers[i].getName(), "");
113:                            break;
114:                        }
115:                    }
116:                    
117:                    assertNotNull(park);
118:                    request.setLayer(park);
119:                    
120:                    request.setFormat("image/gif");
121:                    
122:                    request.setWidth("50");
123:                    request.setHeight("50");
124:                    
125:                    System.out.println(request.getFinalURL());
126:                    
127:                    GetLegendGraphicResponse response = (GetLegendGraphicResponse) wms.issueRequest(request);
128:                    assertNotNull(response);
129:                    
130:                    assertEquals(response.getContentType(), "image/gif");
131:                    
132:                    BufferedImage image = ImageIO.read(response.getInputStream());
133:                    assertEquals(image.getHeight(), 50);
134:                } catch(java.net.ConnectException ce){
135:                    if(ce.getMessage().indexOf("timed out")>0){
136:                        System.err.println("Unable to test - timed out: "+ce);
137:                    } else{
138:                        throw(ce);
139:                    }
140:                }
141:                 */
142:            }
143:
144:            //Cannot test 1.1.0 versioning.. I don't have a 1.1.0 server that will do GetStyles
145:            //    public void testCreateGetStylesRequest() throws Exception {
146:            //        WebMapServer wms = new CustomWMS(getStylesURL);
147:            //
148:            //        GetStylesRequest request = wms.createGetStylesRequest();
149:            //        assertNotNull(request);
150:            //
151:            //    }
152:
153:            public void testCreateParser() throws Exception {
154:                WMSCapabilities capabilities = createCapabilities("1.1.0Capabilities.xml");
155:                try {
156:                    assertEquals(capabilities.getVersion(), "1.1.0");
157:                    assertEquals(capabilities.getService().getName(), "OGC:WMS");
158:                    assertEquals(capabilities.getService().getTitle(),
159:                            "GMap WMS Demo Server");
160:                    assertNotNull(capabilities.getService().get_abstract());
161:                    assertEquals(
162:                            capabilities.getService().getOnlineResource(),
163:                            new URL(
164:                                    "http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
165:                    assertNull(capabilities.getService().getKeywordList());
166:
167:                    assertEquals(capabilities.getRequest().getGetCapabilities()
168:                            .getFormats().size(), 1);
169:                    assertEquals(capabilities.getRequest().getGetCapabilities()
170:                            .getFormats().get(0), "application/vnd.ogc.wms_xml");
171:                    assertEquals(capabilities.getRequest().getGetCapabilities()
172:                            .getGet(), new URL(
173:                            "http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
174:                    assertEquals(capabilities.getRequest().getGetCapabilities()
175:                            .getPost(), new URL(
176:                            "http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
177:
178:                    assertEquals(capabilities.getRequest().getGetMap()
179:                            .getFormats().size(), 7);
180:                    assertEquals(capabilities.getRequest().getGetMap()
181:                            .getFormats().get(0), "image/gif");
182:                    assertEquals(capabilities.getRequest().getGetMap()
183:                            .getFormats().get(3), "image/wbmp");
184:                    assertEquals(capabilities.getRequest().getGetMap()
185:                            .getFormats().get(6), "image/tiff");
186:                    assertEquals(
187:                            capabilities.getRequest().getGetMap().getGet(),
188:                            new URL(
189:                                    "http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
190:                    assertEquals(capabilities.getRequest().getGetMap()
191:                            .getPost(), new URL(
192:                            "http://dev1.dmsolutions.ca/cgi-bin/mswms_gmap?"));
193:
194:                    assertEquals(capabilities.getRequest().getGetFeatureInfo()
195:                            .getFormats().size(), 3);
196:                    assertEquals(capabilities.getRequest().getGetFeatureInfo()
197:                            .getFormats().get(0), "text/plain");
198:                    assertEquals(capabilities.getRequest().getGetFeatureInfo()
199:                            .getFormats().get(1), "text/html");
200:                    assertEquals(capabilities.getRequest().getGetFeatureInfo()
201:                            .getFormats().get(2), "application/vnd.ogc.gml");
202:
203:                    assertEquals(capabilities.getLayerList().size(), 12);
204:
205:                    Layer layer = (Layer) capabilities.getLayerList().get(0);
206:                    assertNull(layer.getParent());
207:                    assertEquals(layer.getName(), "DEMO");
208:                    assertEquals(layer.get_abstract(), "Abstract Test");
209:                    String[] keywords = layer.getKeywords();
210:                    assertNotNull(keywords);
211:                    assertEquals(keywords.length, 2);
212:                    assertEquals(keywords[0], "word1");
213:                    assertEquals(keywords[1], "word2");
214:                    assertEquals(layer.getTitle(), "GMap WMS Demo Server");
215:                    assertEquals(layer.getSrs().size(), 4);
216:                    assertTrue(layer.getSrs().contains("EPSG:42304"));
217:                    assertTrue(layer.getSrs().contains("EPSG:42101"));
218:                    assertTrue(layer.getSrs().contains("EPSG:4269"));
219:                    assertTrue(layer.getSrs().contains("EPSG:4326"));
220:
221:                    CRSEnvelope llbbox = layer.getLatLonBoundingBox();
222:                    validateBoundingBox(llbbox, -172.367, 35.6673, -11.5624,
223:                            83.8293);
224:
225:                    assertEquals(layer.getBoundingBoxes().size(), 1);
226:                    assertNotNull(layer.getBoundingBoxes().get("EPSG:42304"));
227:
228:                    Layer layer2 = (Layer) capabilities.getLayerList().get(1);
229:                    assertEquals(layer2.getParent(), layer);
230:                    assertEquals(layer2.getName(), "bathymetry");
231:                    assertEquals(layer2.getTitle(), "Elevation/Bathymetry");
232:                    assertTrue(layer2.getSrs().contains("EPSG:42304"));
233:                    assertFalse(layer2.isQueryable());
234:
235:                    layer2 = (Layer) capabilities.getLayerList().get(2);
236:                    assertEquals(layer2.getParent(), layer);
237:                    assertEquals(layer2.getName(), "land_fn");
238:                    assertEquals(layer2.getTitle(), "Foreign Lands");
239:
240:                    validateBoundingBox(layer2.getLatLonBoundingBox(),
241:                            -178.838, 31.8844, 179.94, 89.8254);
242:
243:                    assertTrue(layer2.getSrs().contains("EPSG:42304"));
244:                    assertFalse(layer2.isQueryable());
245:                    assertNotNull(layer2.getBoundingBoxes().get("EPSG:42304"));
246:
247:                    layer2 = (Layer) capabilities.getLayerList().get(3);
248:                    assertEquals(layer2.getParent(), layer);
249:                    assertEquals(layer2.getName(), "park");
250:                    assertEquals(layer2.getTitle(), "Parks");
251:
252:                    validateBoundingBox(layer2.getLatLonBoundingBox(),
253:                            -173.433, 41.4271, -13.3643, 83.7466);
254:
255:                    assertTrue(layer2.getSrs().contains("EPSG:42304"));
256:                    assertTrue(layer2.isQueryable());
257:                    assertNotNull(layer2.getBoundingBoxes().get("EPSG:42304"));
258:
259:                    layer2 = (Layer) capabilities.getLayerList().get(11);
260:                    assertEquals(layer2.getParent(), layer);
261:                    assertEquals(layer2.getName(), "grid");
262:                    assertEquals(layer2.getTitle(), "Grid");
263:
264:                    llbbox = layer2.getLatLonBoundingBox();
265:                    validateBoundingBox(llbbox, -178.838, 31.8844, 179.94,
266:                            89.8254);
267:
268:                    assertTrue(layer2.getSrs().contains("EPSG:42304"));
269:                    assertFalse(layer2.isQueryable());
270:                    assertNotNull(layer2.getBoundingBoxes().get("EPSG:42304"));
271:                } catch (Exception e) {
272:                    if (e.getMessage().indexOf("timed out") > 0) {
273:                        System.err.println("Unable to test - timed out: " + e);
274:                    } else {
275:                        throw (e);
276:                    }
277:                }
278:            }
279:
280:            public void testCreateGetMapRequest() throws Exception {
281:                try {
282:                    WebMapServer wms = new WebMapServer(server);
283:                    WMSCapabilities caps = wms.getCapabilities();
284:                    GetMapRequest request = wms.createGetMapRequest();
285:                    request.setFormat("image/jpeg");
286:                    //System.out.println(request.getFinalURL().toExternalForm());
287:
288:                    assertTrue(request.getFinalURL().toExternalForm().indexOf(
289:                            "image/jpeg") >= 0);
290:                } catch (java.net.ConnectException ce) {
291:                    if (ce.getMessage().indexOf("timed out") > 0) {
292:                        System.err.println("Unable to test - timed out: " + ce);
293:                    } else {
294:                        throw (ce);
295:                    }
296:                }
297:            }
298:
299:            protected WebMapServer getCustomWMS(URL featureURL)
300:                    throws SAXException, URISyntaxException, IOException {
301:                return new CustomWMS(featureURL);
302:            }
303:
304:            protected void validateBoundingBox(CRSEnvelope llbbox, double minX,
305:                    double minY, double maxX, double maxY) {
306:                assertNotNull(llbbox);
307:                assertEquals(llbbox.getMinX(), minX, 0.0);
308:                assertEquals(llbbox.getMinY(), minY, 0.0);
309:                assertEquals(llbbox.getMaxX(), maxX, 0.0);
310:                assertEquals(llbbox.getMaxY(), maxY, 0.0);
311:            }
312:
313:            //forces use of 1.1.0 spec
314:            private class CustomWMS extends WebMapServer {
315:
316:                /**
317:                 * @param serverURL
318:                 * @param wait
319:                 * @throws SAXException
320:                 * @throws URISyntaxException
321:                 * @throws IOException
322:                 */
323:                public CustomWMS(URL serverURL) throws SAXException,
324:                        URISyntaxException, IOException {
325:                    super (serverURL);
326:                    // TODO Auto-generated constructor stub
327:                }
328:
329:                protected void setupSpecifications() {
330:                    specs = new Specification[1];
331:                    specs[0] = new WMS1_1_0();
332:                }
333:            }
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.