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 */
017package org.apache.commons.chain.web.jakarta.servlet;
018
019import java.io.IOException;
020import java.io.PrintWriter;
021import java.util.Collection;
022import java.util.Locale;
023
024import jakarta.servlet.ServletOutputStream;
025import jakarta.servlet.http.Cookie;
026import jakarta.servlet.http.HttpServletResponse;
027
028/**
029 * Mock Object for {@code HttpServletResponse} (Version 2.3)
030 */
031public class MockHttpServletResponse implements HttpServletResponse {
032
033    // ------------------------------------------------------ Instance Variables
034
035    private Locale locale = null;
036
037    // ------------------------------------------------------------ Constructors
038
039    /**
040     * The Default-Constructor for this class.
041     */
042    public MockHttpServletResponse() {
043    }
044
045    // ---------------------------------------------------------- Public Methods
046
047    // --------------------------------------------- HttpServletResponse Methods
048
049    @Override
050    public void addCookie(Cookie cookie) {
051        throw new UnsupportedOperationException();
052    }
053
054    @Override
055    public void addDateHeader(String name, long value) {
056        throw new UnsupportedOperationException();
057    }
058
059    @Override
060    public void addHeader(String name, String value) {
061        throw new UnsupportedOperationException();
062    }
063
064    @Override
065    public void addIntHeader(String name, int value) {
066        throw new UnsupportedOperationException();
067    }
068
069    @Override
070    public boolean containsHeader(String name) {
071        throw new UnsupportedOperationException();
072    }
073
074    @Deprecated
075    @Override
076    public String encodeRedirectUrl(String url) {
077        return encodeRedirectURL(url);
078    }
079
080    @Override
081    public String encodeRedirectURL(String url) {
082        return url;
083    }
084
085    @Deprecated
086    @Override
087    public String encodeUrl(String url) {
088        return encodeURL(url);
089    }
090
091    @Override
092    public String encodeURL(String url) {
093        return url;
094    }
095
096    @Override
097    public void sendError(int status) {
098        throw new UnsupportedOperationException();
099    }
100
101    @Override
102    public void sendError(int status, String message) {
103        throw new UnsupportedOperationException();
104    }
105
106    @Override
107    public void sendRedirect(String location) {
108        throw new UnsupportedOperationException();
109    }
110
111    @Override
112    public void setDateHeader(String name, long value) {
113        throw new UnsupportedOperationException();
114    }
115
116    @Override
117    public void setHeader(String name, String value) {
118        throw new UnsupportedOperationException();
119    }
120
121    @Override
122    public void setIntHeader(String name, int value) {
123        throw new UnsupportedOperationException();
124    }
125
126    @Override
127    public void setStatus(int status) {
128        throw new UnsupportedOperationException();
129    }
130
131    @Deprecated
132    @Override
133    public void setStatus(int status, String message) {
134        throw new UnsupportedOperationException();
135    }
136
137    // ------------------------------------------------- ServletResponse Methods
138
139    @Override
140    public void flushBuffer() {
141        throw new UnsupportedOperationException();
142    }
143
144    @Override
145    public int getBufferSize() {
146        throw new UnsupportedOperationException();
147    }
148
149    @Override
150    public String getCharacterEncoding() {
151        throw new UnsupportedOperationException();
152    }
153
154    public String getContentType() {
155        throw new UnsupportedOperationException();
156    }
157
158    @Override
159    public Locale getLocale() {
160        return this.locale;
161    }
162
163    @Override
164    public ServletOutputStream getOutputStream() throws IOException {
165        throw new UnsupportedOperationException();
166    }
167
168    @Override
169    public PrintWriter getWriter() throws IOException {
170        throw new UnsupportedOperationException();
171    }
172
173    @Override
174    public boolean isCommitted() {
175        throw new UnsupportedOperationException();
176    }
177
178    @Override
179    public void reset() {
180        throw new UnsupportedOperationException();
181    }
182
183    @Override
184    public void resetBuffer() {
185        throw new UnsupportedOperationException();
186    }
187
188    @Override
189    public void setBufferSize(int size) {
190        throw new UnsupportedOperationException();
191    }
192
193    public void setCharacterEncoding(String encoding) {
194        throw new UnsupportedOperationException();
195    }
196
197    @Override
198    public void setContentLength(int length) {
199        throw new UnsupportedOperationException();
200    }
201
202    @Override
203    public void setContentType(String type) {
204        throw new UnsupportedOperationException();
205    }
206
207    @Override
208    public void setLocale(Locale locale) {
209        this.locale = locale;
210    }
211
212    @Override
213    public void setContentLengthLong(long len) {
214        throw new UnsupportedOperationException();
215    }
216
217    @Override
218    public int getStatus() {
219        throw new UnsupportedOperationException();
220    }
221
222    @Override
223    public String getHeader(String name) {
224        throw new UnsupportedOperationException();
225    }
226
227    @Override
228    public Collection<String> getHeaders(String name) {
229        throw new UnsupportedOperationException();
230    }
231
232    @Override
233    public Collection<String> getHeaderNames() {
234        throw new UnsupportedOperationException();
235    }
236}