Source Code Cross Referenced for GetLegendGraphicKvpReaderTest.java in  » GIS » GeoServer » org » vfny » geoserver » wms » requests » 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 » GeoServer » org.vfny.geoserver.wms.requests 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.vfny.geoserver.wms.requests;
006:
007:        import com.mockrunner.mock.web.MockHttpServletRequest;
008:        import junit.framework.TestCase;
009:        import org.geotools.styling.Style;
010:        import org.vfny.geoserver.Response;
011:        import org.vfny.geoserver.ServiceException;
012:        import org.vfny.geoserver.global.Config;
013:        import org.vfny.geoserver.global.Data;
014:        import org.vfny.geoserver.global.GeoServer;
015:        import org.vfny.geoserver.global.WMS;
016:        import org.vfny.geoserver.servlets.AbstractService;
017:        import org.vfny.geoserver.testdata.MockUtils;
018:        import org.vfny.geoserver.util.requests.readers.KvpRequestReader;
019:        import org.vfny.geoserver.util.requests.readers.XmlRequestReader;
020:        import org.vfny.geoserver.wms.servlets.GetLegendGraphic;
021:        import org.vfny.geoserver.wms.servlets.WMService;
022:        import java.net.URL;
023:        import java.util.HashMap;
024:        import java.util.Map;
025:
026:        public class GetLegendGraphicKvpReaderTest extends TestCase {
027:            /**
028:             * request reader to test against, initialized by default with all
029:             * parameters from <code>requiredParameters</code> and
030:             * <code>optionalParameters</code>
031:             */
032:            GetLegendGraphicKvpReader requestReader;
033:
034:            /** test values for required parameters */
035:            Map requiredParameters;
036:
037:            /** test values for optional parameters */
038:            Map optionalParameters;
039:
040:            /** both required and optional parameters joint up */
041:            Map allParameters;
042:
043:            /** mock request */
044:            MockHttpServletRequest httpRequest;
045:
046:            /** mock servlet */
047:            WMService dummy;
048:
049:            /**
050:             * Remainder:
051:             * <ul>
052:             * <li>VERSION/Required
053:             * <li>REQUEST/Required
054:             * <li>LAYER/Required
055:             * <li>FORMAT/Required
056:             * <li>STYLE/Optional
057:             * <li>FEATURETYPE/Optional
058:             * <li>RULE/Optional
059:             * <li>SCALE/Optional
060:             * <li>SLD/Optional
061:             * <li>SLD_BODY/Optional
062:             * <li>WIDTH/Optional
063:             * <li>HEIGHT/Optional
064:             * <li>EXCEPTIONS/Optional
065:             * </ul>
066:             */
067:            protected void setUp() throws Exception {
068:                super .setUp();
069:                requiredParameters = new HashMap();
070:                requiredParameters.put("VERSION", "1.0.0");
071:                requiredParameters.put("REQUEST", "GetLegendGraphic");
072:                requiredParameters.put("LAYER", "cite:Ponds");
073:                requiredParameters.put("FORMAT", "image/png");
074:
075:                optionalParameters = new HashMap();
076:                optionalParameters.put("STYLE", "Ponds");
077:                optionalParameters.put("FEATURETYPE", "fake_not_used");
078:                // optionalParameters.put("RULE", "testRule");
079:                optionalParameters.put("SCALE", "1000");
080:                optionalParameters.put("WIDTH", "120");
081:                optionalParameters.put("HEIGHT", "90");
082:                // ??optionalParameters.put("EXCEPTIONS", "");
083:                allParameters = new HashMap(requiredParameters);
084:                allParameters.putAll(optionalParameters);
085:
086:                Data data = MockUtils.createTestCiteData(new GeoServer());
087:                WMS wms = new WMS(MockUtils.newWmsDto());
088:                wms.setData(data);
089:
090:                GetLegendGraphic service = new GetLegendGraphic(wms);
091:                this .requestReader = new GetLegendGraphicKvpReader(
092:                        allParameters, service);
093:                this .httpRequest = MockUtils
094:                        .newHttpRequest(allParameters, true);
095:
096:                dummy = new WMService("dummy", wms) {
097:                    protected Response getResponseHandler() {
098:                        return null;
099:                    }
100:
101:                    protected KvpRequestReader getKvpReader(Map params) {
102:                        return null;
103:                    }
104:
105:                    protected XmlRequestReader getXmlRequestReader() {
106:                        return null;
107:                    }
108:                };
109:            }
110:
111:            protected void tearDown() throws Exception {
112:                super .tearDown();
113:            }
114:
115:            // disabled this test for the moment as a 
116:            //	fix for http://jira.codehaus.org/browse/GEOS-710
117:            //	Since at the moment none of the other request do check the version numbers, we 
118:            //	disable this check for the moment, and wait for a proper fix once the 
119:            //	we support more than one version of WMS/WFS specs
120:
121:            //	public void testVersion() throws Exception {
122:            //		requiredParameters.put("VERSION", "WRONG");
123:            //		
124:            //		this.requestReader = 
125:            //			new GetLegendGraphicKvpReader(requiredParameters, dummy);
126:            //		try {
127:            //			requestReader.getRequest(httpRequest);
128:            //			fail("Expected ServiceException due to wrong VERSION parameter");
129:            //		} catch (ServiceException e) {
130:            //			// OK
131:            //		}
132:            //		requiredParameters.put("VERSION", "1.0.0");
133:            //		GetLegendGraphicRequest parsedRequest;
134:            //		parsedRequest = (GetLegendGraphicRequest) requestReader
135:            //				.getRequest(httpRequest);
136:            //	}
137:
138:            /**
139:             * This test ensures that when a SLD parameter has been passed that refers
140:             * to a SLD document with multiple styles, the required one is choosed based
141:             * on the LAYER parameter.
142:             * <p>
143:             * This is the case where a remote SLD document is used in "library" mode.
144:             * </p>
145:             */
146:            public void testRemoteSLDMultipleStyles() throws ServiceException {
147:                final URL remoteSldUrl = getClass().getResource(
148:                        "test-data/MultipleStyles.sld");
149:                this .allParameters.put("SLD", remoteSldUrl.toExternalForm());
150:
151:                this .allParameters.put("LAYER", "cite:Ponds");
152:                this .allParameters.put("STYLE", "Ponds");
153:                requestReader = new GetLegendGraphicKvpReader(
154:                        this .allParameters, dummy);
155:
156:                GetLegendGraphicRequest request = (GetLegendGraphicRequest) requestReader
157:                        .getRequest(httpRequest);
158:
159:                //the style names Ponds is declared in third position on the sld doc
160:                Style selectedStyle = request.getStyle();
161:                assertNotNull(selectedStyle);
162:                assertEquals("Ponds", selectedStyle.getName());
163:
164:                this .allParameters.put("LAYER", "cite:Lakes");
165:                this .allParameters.put("STYLE", "Lakes");
166:                requestReader = new GetLegendGraphicKvpReader(
167:                        this .allParameters, dummy);
168:                request = (GetLegendGraphicRequest) requestReader
169:                        .getRequest(httpRequest);
170:
171:                //the style names Ponds is declared in third position on the sld doc
172:                selectedStyle = request.getStyle();
173:                assertNotNull(selectedStyle);
174:                assertEquals("Lakes", selectedStyle.getName());
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.