View Javadoc
1   /**
2    * Logback: the reliable, generic, fast and flexible logging framework.
3    * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4    *
5    * This program and the accompanying materials are dual-licensed under
6    * either the terms of the Eclipse Public License v1.0 as published by
7    * the Eclipse Foundation
8    *
9    *   or (per the licensee's choosing)
10   *
11   * under the terms of the GNU Lesser General Public License version 2.1
12   * as published by the Free Software Foundation.
13   */
14  package ch.qos.logback.access.dummy;
15  
16  import java.io.IOException;
17  import java.io.PrintWriter;
18  import java.util.*;
19  
20  import javax.servlet.ServletOutputStream;
21  import javax.servlet.http.Cookie;
22  import javax.servlet.http.HttpServletResponse;
23  
24  public class DummyResponse implements HttpServletResponse {
25  
26      public static final int DUMMY_DEFAULT_STATUS = 200;
27      public static final int DUMMY_DEFAULT_CONTENT_COUNT = 1000;
28      public static final Map<String, String> DUMMY_DEFAULT_HDEADER_MAP = new HashMap<String, String>();;
29  
30      static {
31          DUMMY_DEFAULT_HDEADER_MAP.put("headerName1", "headerValue1");
32          DUMMY_DEFAULT_HDEADER_MAP.put("headerName2", "headerValue2");
33      }
34  
35      int status = DUMMY_DEFAULT_STATUS;
36      public Map<String, String> headerMap;
37  
38      String characterEncoding = null;
39      ServletOutputStream outputStream = null;
40  
41      public DummyResponse() {
42          headerMap = DUMMY_DEFAULT_HDEADER_MAP;
43      }
44  
45      public void addCookie(Cookie arg0) {
46      }
47  
48      public void addDateHeader(String arg0, long arg1) {
49      }
50  
51      public void addHeader(String arg0, String arg1) {
52      }
53  
54      public void addIntHeader(String arg0, int arg1) {
55      }
56  
57      public boolean containsHeader(String arg0) {
58          return false;
59      }
60  
61      public String encodeRedirectURL(String arg0) {
62          return null;
63      }
64  
65      public String encodeRedirectUrl(String arg0) {
66          return null;
67      }
68  
69      public String encodeURL(String arg0) {
70          return null;
71      }
72  
73      public String encodeUrl(String arg0) {
74          return null;
75      }
76  
77      public void sendError(int arg0) throws IOException {
78      }
79  
80      public void sendError(int arg0, String arg1) throws IOException {
81      }
82  
83      public void sendRedirect(String arg0) throws IOException {
84      }
85  
86      public void setDateHeader(String arg0, long arg1) {
87      }
88  
89      public void setHeader(String arg0, String arg1) {
90      }
91  
92      public void setIntHeader(String arg0, int arg1) {
93      }
94  
95      public void setStatus(int arg0, String arg1) {
96      }
97  
98      public void flushBuffer() throws IOException {
99      }
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 }