Source Code Cross Referenced for MockExternalContext.java in  » Workflow-Engines » spring-webflow-1.0.4 » org » springframework » webflow » 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 » Workflow Engines » spring webflow 1.0.4 » org.springframework.webflow.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2004-2007 the original author or authors.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package org.springframework.webflow.test;
017:
018:        import java.util.HashMap;
019:
020:        import org.springframework.binding.collection.SharedMapDecorator;
021:        import org.springframework.webflow.context.ExternalContext;
022:        import org.springframework.webflow.core.collection.LocalAttributeMap;
023:        import org.springframework.webflow.core.collection.LocalSharedAttributeMap;
024:        import org.springframework.webflow.core.collection.MutableAttributeMap;
025:        import org.springframework.webflow.core.collection.ParameterMap;
026:        import org.springframework.webflow.core.collection.SharedAttributeMap;
027:
028:        /**
029:         * Mock implementation of the {@link ExternalContext} interface.
030:         * 
031:         * @see ExternalContext
032:         * 
033:         * @author Keith Donald
034:         */
035:        public class MockExternalContext implements  ExternalContext {
036:
037:            private String contextPath;
038:
039:            private String dispatcherPath;
040:
041:            private String requestPathInfo;
042:
043:            private ParameterMap requestParameterMap = new MockParameterMap();
044:
045:            private MutableAttributeMap requestMap = new LocalAttributeMap();
046:
047:            private SharedAttributeMap sessionMap = new LocalSharedAttributeMap(
048:                    new SharedMapDecorator(new HashMap()));
049:
050:            private SharedAttributeMap globalSessionMap = sessionMap;
051:
052:            private SharedAttributeMap applicationMap = new LocalSharedAttributeMap(
053:                    new SharedMapDecorator(new HashMap()));
054:
055:            /**
056:             * Creates a mock external context with an empty request parameter map.
057:             * Allows for bean style usage.
058:             */
059:            public MockExternalContext() {
060:            }
061:
062:            /**
063:             * Creates a mock external context with the specified parameters in the
064:             * request parameter map. All other properties of the external context
065:             * can be set using the appropriate setter.
066:             * @param requestParameterMap the request parameters
067:             */
068:            public MockExternalContext(ParameterMap requestParameterMap) {
069:                if (requestParameterMap != null) {
070:                    this .requestParameterMap = requestParameterMap;
071:                }
072:            }
073:
074:            // implementing external context
075:
076:            public String getContextPath() {
077:                return contextPath;
078:            }
079:
080:            public String getDispatcherPath() {
081:                return dispatcherPath;
082:            }
083:
084:            public String getRequestPathInfo() {
085:                return requestPathInfo;
086:            }
087:
088:            public ParameterMap getRequestParameterMap() {
089:                return requestParameterMap;
090:            }
091:
092:            public MutableAttributeMap getRequestMap() {
093:                return requestMap;
094:            }
095:
096:            public SharedAttributeMap getSessionMap() {
097:                return sessionMap;
098:            }
099:
100:            public SharedAttributeMap getGlobalSessionMap() {
101:                return globalSessionMap;
102:            }
103:
104:            public SharedAttributeMap getApplicationMap() {
105:                return applicationMap;
106:            }
107:
108:            // helper setters
109:
110:            /**
111:             * Set the context path.
112:             * @see ExternalContext#getContextPath()
113:             */
114:            public void setContextPath(String contextPath) {
115:                this .contextPath = contextPath;
116:            }
117:
118:            /**
119:             * Set the dispatcher path.
120:             * @see ExternalContext#getDispatcherPath()
121:             */
122:            public void setDispatcherPath(String dispatcherPath) {
123:                this .dispatcherPath = dispatcherPath;
124:            }
125:
126:            /**
127:             * Set the request path info.
128:             * @see ExternalContext#getRequestPathInfo()
129:             */
130:            public void setRequestPathInfo(String requestPathInfo) {
131:                this .requestPathInfo = requestPathInfo;
132:            }
133:
134:            /**
135:             * Set the request parameter map.
136:             * @see ExternalContext#getRequestParameterMap()
137:             */
138:            public void setRequestParameterMap(ParameterMap requestParameterMap) {
139:                this .requestParameterMap = requestParameterMap;
140:            }
141:
142:            /**
143:             * Set the request attribute map.
144:             * @see ExternalContext#getRequestMap()
145:             */
146:            public void setRequestMap(MutableAttributeMap requestMap) {
147:                this .requestMap = requestMap;
148:            }
149:
150:            /**
151:             * Set the session attribute map.
152:             * @see ExternalContext#getSessionMap()
153:             */
154:            public void setSessionMap(SharedAttributeMap sessionMap) {
155:                this .sessionMap = sessionMap;
156:            }
157:
158:            /**
159:             * Set the global session attribute map. By default the session attribute
160:             * map and the global session attribute map are one and the same.
161:             * @see ExternalContext#getGlobalSessionMap()
162:             */
163:            public void setGlobalSessionMap(SharedAttributeMap globalSessionMap) {
164:                this .globalSessionMap = globalSessionMap;
165:            }
166:
167:            /**
168:             * Set the application attribute map.
169:             * @see ExternalContext#getApplicationMap()
170:             */
171:            public void setApplicationMap(SharedAttributeMap applicationMap) {
172:                this .applicationMap = applicationMap;
173:            }
174:
175:            // convenience helpers
176:
177:            /**
178:             * Returns the request parameter map as a {@link MockParameterMap}
179:             * for convenient access in a unit test.
180:             * @see #getRequestParameterMap()
181:             */
182:            public MockParameterMap getMockRequestParameterMap() {
183:                return (MockParameterMap) requestParameterMap;
184:            }
185:
186:            /**
187:             * Puts a request parameter into the mock parameter map.
188:             * @param parameterName the parameter name
189:             * @param parameterValue the parameter value
190:             */
191:            public void putRequestParameter(String parameterName,
192:                    String parameterValue) {
193:                getMockRequestParameterMap().put(parameterName, parameterValue);
194:            }
195:
196:            /**
197:             * Puts a multi-valued request parameter into the mock parameter map.
198:             * @param parameterName the parameter name
199:             * @param parameterValues the parameter values
200:             */
201:            public void putRequestParameter(String parameterName,
202:                    String[] parameterValues) {
203:                getMockRequestParameterMap()
204:                        .put(parameterName, parameterValues);
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.