001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.access.dummy;
015
016import java.io.IOException;
017import java.io.PrintWriter;
018import java.util.*;
019
020import javax.servlet.ServletOutputStream;
021import javax.servlet.http.Cookie;
022import javax.servlet.http.HttpServletResponse;
023
024public class DummyResponse implements HttpServletResponse {
025
026    public static final int DUMMY_DEFAULT_STATUS = 200;
027    public static final int DUMMY_DEFAULT_CONTENT_COUNT = 1000;
028    public static final Map<String, String> DUMMY_DEFAULT_HDEADER_MAP = new HashMap<String, String>();;
029
030    static {
031        DUMMY_DEFAULT_HDEADER_MAP.put("headerName1", "headerValue1");
032        DUMMY_DEFAULT_HDEADER_MAP.put("headerName2", "headerValue2");
033    }
034
035    int status = DUMMY_DEFAULT_STATUS;
036    public Map<String, String> headerMap;
037
038    String characterEncoding = null;
039    ServletOutputStream outputStream = null;
040
041    public DummyResponse() {
042        headerMap = DUMMY_DEFAULT_HDEADER_MAP;
043    }
044
045    public void addCookie(Cookie arg0) {
046    }
047
048    public void addDateHeader(String arg0, long arg1) {
049    }
050
051    public void addHeader(String arg0, String arg1) {
052    }
053
054    public void addIntHeader(String arg0, int arg1) {
055    }
056
057    public boolean containsHeader(String arg0) {
058        return false;
059    }
060
061    public String encodeRedirectURL(String arg0) {
062        return null;
063    }
064
065    public String encodeRedirectUrl(String arg0) {
066        return null;
067    }
068
069    public String encodeURL(String arg0) {
070        return null;
071    }
072
073    public String encodeUrl(String arg0) {
074        return null;
075    }
076
077    public void sendError(int arg0) throws IOException {
078    }
079
080    public void sendError(int arg0, String arg1) throws IOException {
081    }
082
083    public void sendRedirect(String arg0) throws IOException {
084    }
085
086    public void setDateHeader(String arg0, long arg1) {
087    }
088
089    public void setHeader(String arg0, String arg1) {
090    }
091
092    public void setIntHeader(String arg0, int arg1) {
093    }
094
095    public void setStatus(int arg0, String arg1) {
096    }
097
098    public void flushBuffer() throws IOException {
099    }
100
101    public int getBufferSize() {
102        return 0;
103    }
104
105    public String getCharacterEncoding() {
106        return characterEncoding;
107    }
108
109    public String getContentType() {
110        return null;
111    }
112
113    public Locale getLocale() {
114        return null;
115    }
116
117    public ServletOutputStream getOutputStream() throws IOException {
118        return outputStream;
119    }
120
121    public void setOutputStream(ServletOutputStream outputStream) {
122        this.outputStream = outputStream;
123    }
124
125    public PrintWriter getWriter() throws IOException {
126        return null;
127    }
128
129    public boolean isCommitted() {
130        return false;
131    }
132
133    public void reset() {
134    }
135
136    public void resetBuffer() {
137    }
138
139    public void setBufferSize(int arg0) {
140    }
141
142    public void setCharacterEncoding(String characterEncoding) {
143        this.characterEncoding = characterEncoding;
144    }
145
146    public void setContentLength(int arg0) {
147    }
148
149    public void setContentType(String arg0) {
150    }
151
152    public void setLocale(Locale arg0) {
153    }
154
155    public String getHeader(String key) {
156        return headerMap.get(key);
157    }
158
159    public Collection<String> getHeaders(String name) {
160        String val = headerMap.get(name);
161        List<String> list = new ArrayList<String>();
162        if (val != null)
163            list.add(val);
164        return list;
165    }
166
167    public Collection<String> getHeaderNames() {
168        return headerMap.keySet();
169    }
170
171    public long getContentCount() {
172        return DUMMY_DEFAULT_CONTENT_COUNT;
173    }
174
175    public int getStatus() {
176        return status;
177    }
178
179    public void setStatus(int status) {
180        this.status = status;
181    }
182
183    @Override
184    public void setContentLengthLong(long length) {
185        // TODO Auto-generated method stub
186    }
187
188}