01: /*
02: * Copyright 2004-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.springframework.webflow.test;
17:
18: import java.util.HashMap;
19:
20: import org.springframework.webflow.core.collection.LocalParameterMap;
21: import org.springframework.webflow.core.collection.ParameterMap;
22:
23: /**
24: * A extension of parameter map that allows for mutation of parameters. Useful
25: * as a stub for testing.
26: *
27: * @see ParameterMap
28: *
29: * @author Keith Donald
30: */
31: public class MockParameterMap extends LocalParameterMap {
32:
33: /**
34: * Creates a new parameter map, initially empty.
35: */
36: public MockParameterMap() {
37: super (new HashMap());
38: }
39:
40: /**
41: * Add a new parameter to this map.
42: * @param parameterName the parameter name
43: * @param parameterValue the parameter value
44: * @return this, to support call chaining
45: */
46: public MockParameterMap put(String parameterName,
47: String parameterValue) {
48: getMapInternal().put(parameterName, parameterValue);
49: return this ;
50: }
51:
52: /**
53: * Add a new multi-valued parameter to this map.
54: * @param parameterName the parameter name
55: * @param parameterValues the parameter values
56: * @return this, to support call chaining
57: */
58: public MockParameterMap put(String parameterName,
59: String[] parameterValues) {
60: getMapInternal().put(parameterName, parameterValues);
61: return this;
62: }
63: }
|