001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.environment.mock;
018:
019: import java.util.Locale;
020: import java.util.HashMap;
021: import java.util.HashSet;
022: import java.util.Map;
023: import java.util.Set;
024:
025: import junit.framework.AssertionFailedError;
026:
027: import org.apache.cocoon.environment.Cookie;
028: import org.apache.cocoon.environment.Response;
029:
030: public class MockResponse implements Response {
031:
032: private String encoding;
033: private Locale locale;
034: private HashSet cookies = new HashSet();
035: private HashMap header = new HashMap();
036:
037: public void setCharacterEncoding(String encoding) {
038: this .encoding = encoding;
039: }
040:
041: public String getCharacterEncoding() {
042: return encoding;
043: }
044:
045: public void setLocale(Locale locale) {
046: this .locale = locale;
047: }
048:
049: public Locale getLocale() {
050: return locale;
051: }
052:
053: public Cookie createCookie(String name, String value) {
054: MockCookie cookie = new MockCookie();
055: cookie.setName(name);
056: cookie.setValue(value);
057: return cookie;
058: }
059:
060: public void addCookie(Cookie cookie) {
061: cookies.add(cookie);
062: }
063:
064: public Set getCookies() {
065: return cookies;
066: }
067:
068: public boolean containsHeader(String name) {
069: return header.containsKey(name);
070: }
071:
072: public String encodeURL(String url) {
073: throw new AssertionFailedError("Not implemented");
074: }
075:
076: public void setDateHeader(String name, long date) {
077: header.put(name, new Long(date));
078: }
079:
080: public void addDateHeader(String name, long date) {
081: header.put(name, new Long(date));
082: }
083:
084: public void setHeader(String name, String value) {
085: header.put(name, value);
086: }
087:
088: public void addHeader(String name, String value) {
089: header.put(name, value);
090: }
091:
092: public void setIntHeader(String name, int value) {
093: header.put(name, new Integer(value));
094: }
095:
096: public void addIntHeader(String name, int value) {
097: header.put(name, new Integer(value));
098: }
099:
100: public Map getHeader() {
101: return header;
102: }
103:
104: public void reset() {
105: encoding = null;
106: locale = null;
107: cookies.clear();
108: header.clear();
109: }
110: }
|