001: // Copyright 2007 The Apache Software Foundation
002: //
003: // Licensed under the Apache License, Version 2.0 (the "License");
004: // you may not use this file except in compliance with the License.
005: // You may obtain a copy of the License at
006: //
007: // http://www.apache.org/licenses/LICENSE-2.0
008: //
009: // Unless required by applicable law or agreed to in writing, software
010: // distributed under the License is distributed on an "AS IS" BASIS,
011: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012: // See the License for the specific language governing permissions and
013: // limitations under the License.
014:
015: package org.apache.tapestry.internal.test;
016:
017: import static org.apache.tapestry.ioc.internal.util.CollectionFactory.newMap;
018:
019: import java.util.List;
020: import java.util.Locale;
021: import java.util.Map;
022:
023: import org.apache.tapestry.ioc.internal.util.InternalUtils;
024: import org.apache.tapestry.services.Session;
025:
026: public class TestableRequestImpl implements TestableRequest {
027: private final String _contextPath;
028:
029: private final Map<String, String> _parameters = newMap();
030:
031: private Session _session;
032:
033: public TestableRequestImpl() {
034: this ("/foo");
035: }
036:
037: public TestableRequestImpl(String contextPath) {
038: _contextPath = contextPath;
039: }
040:
041: private void nyi(String methodName) {
042: throw new RuntimeException(
043: String
044: .format(
045: "Request: method %s() not yet implemented by TestableRequestImpl.",
046: methodName));
047: }
048:
049: public void clear() {
050: _parameters.clear();
051: }
052:
053: public void loadParameter(String parameterName,
054: String parameterValue) {
055: _parameters.put(parameterName, parameterValue);
056: }
057:
058: public void loadParameters(Map<String, String> parameterValues) {
059: _parameters.putAll(parameterValues);
060: }
061:
062: public long getDateHeader(String name) {
063: nyi("getDateHeader");
064:
065: return 0;
066: }
067:
068: public String getHeader(String name) {
069: nyi("getHeader");
070:
071: return null;
072: }
073:
074: public List<String> getHeaderNames() {
075: nyi("getHeaderNames");
076:
077: return null;
078: }
079:
080: public Locale getLocale() {
081: nyi("getLocale");
082:
083: return null;
084: }
085:
086: public List<String> getParameterNames() {
087: return InternalUtils.sortedKeys(_parameters);
088: }
089:
090: public String[] getParameters(String name) {
091: nyi("getParameters");
092:
093: return null;
094: }
095:
096: public String getPath() {
097: nyi("getPath");
098:
099: return null;
100: }
101:
102: public String getContextPath() {
103: return _contextPath;
104: }
105:
106: public String getParameter(String name) {
107: return _parameters.get(name);
108: }
109:
110: public Session getSession(boolean create) {
111: if (!create)
112: return _session;
113:
114: if (_session == null)
115: _session = new PageTesterSession();
116:
117: return _session;
118: }
119:
120: public void setEncoding(String requestEncoding) {
121: }
122:
123: }
|