01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.data.wms.test;
17:
18: import java.io.IOException;
19: import java.io.InputStream;
20: import java.net.URL;
21: import java.util.Properties;
22:
23: import junit.framework.TestCase;
24:
25: import org.geotools.data.ows.Response;
26: import org.geotools.data.wms.request.AbstractGetMapRequest;
27: import org.geotools.data.wms.request.GetMapRequest;
28: import org.geotools.ows.ServiceException;
29:
30: public class AbstractGetMapRequestTest extends TestCase {
31:
32: public void testGetFinalURL() throws Exception {
33: URL badURL = new URL(
34: "http://test.com/map.php?LAYERS=Provincial Boundary");
35:
36: GetMapRequest request = new RequestTestHelp(badURL, null);
37:
38: request.addLayer("Provincial Boundary", "Two words");
39: request.addLayer("Layer2", "");
40:
41: URL finalURL = request.getFinalURL();
42: //System.out.println(finalURL);
43: String processedURL = finalURL.toExternalForm();
44: assertTrue(processedURL
45: .indexOf("LAYERS=Layer2,Provincial+Boundary") != -1);
46: assertTrue(processedURL.indexOf("STYLES=,Two+words") != -1);
47: assertTrue(processedURL.indexOf("SERVICE=WMS") != -1);
48: }
49:
50: private class RequestTestHelp extends AbstractGetMapRequest {
51:
52: /**
53: * @param onlineResource
54: * @param properties
55: * @param availableLayers
56: * @param availableSRSs
57: * @param availableFormats
58: * @param availableExceptions
59: */
60: public RequestTestHelp(URL onlineResource, Properties properties) {
61: super (onlineResource, properties);
62: // TODO Auto-generated constructor stub
63: }
64:
65: /* (non-Javadoc)
66: * @see org.geotools.data.wms.request.AbstractGetMapRequest#initVersion()
67: */
68: protected void initVersion() {
69: // TODO Auto-generated method stub
70:
71: }
72:
73: public Response createResponse(String contentType,
74: InputStream inputStream) throws ServiceException,
75: IOException {
76: // TODO Auto-generated method stub
77: return null;
78: }
79:
80: }
81:
82: }
|