1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.struts.mock;
19
20 import javax.servlet.ServletOutputStream;
21 import javax.servlet.http.Cookie;
22 import javax.servlet.http.HttpServletResponse;
23
24 import java.io.IOException;
25 import java.io.PrintWriter;
26
27 import java.util.Locale;
28
29 /***
30 * <p>Mock <strong>HttpServletResponse</strong> object for low-level unit
31 * tests of Struts controller components. Coarser grained tests should be
32 * implemented in terms of the Cactus framework, instead of the mock object
33 * classes.</p>
34 *
35 * <p><strong>WARNING</strong> - Only the minimal set of methods needed to
36 * create unit tests is provided, plus additional methods to configure this
37 * object as necessary. Methods for unsupported operations will throw
38 * <code>UnsupportedOperationException</code>.</p>
39 *
40 * <p><strong>WARNING</strong> - Because unit tests operate in a single
41 * threaded environment, no synchronization is performed.</p>
42 *
43 * @version $Rev: 421119 $ $Date: 2005-05-07 12:11:38 -0400 (Sat, 07 May 2005)
44 * $
45 */
46 public class MockHttpServletResponse implements HttpServletResponse {
47
48
49
50 public void addCookie(Cookie cookie) {
51 throw new UnsupportedOperationException();
52 }
53
54 public void addDateHeader(String name, long value) {
55 throw new UnsupportedOperationException();
56 }
57
58 public void addHeader(String name, String value) {
59 throw new UnsupportedOperationException();
60 }
61
62 public void addIntHeader(String name, int value) {
63 throw new UnsupportedOperationException();
64 }
65
66 public boolean containsHeader(String name) {
67 throw new UnsupportedOperationException();
68 }
69
70 public String encodeRedirectUrl(String url) {
71 return (encodeRedirectURL(url));
72 }
73
74 public String encodeRedirectURL(String url) {
75 return (url);
76 }
77
78 public String encodeUrl(String url) {
79 return (encodeURL(url));
80 }
81
82 public String encodeURL(String url) {
83 return (url);
84 }
85
86 public void sendError(int status) {
87 throw new UnsupportedOperationException();
88 }
89
90 public void sendError(int status, String message) {
91 throw new UnsupportedOperationException();
92 }
93
94 public void sendRedirect(String location) {
95 throw new UnsupportedOperationException();
96 }
97
98 public void setDateHeader(String name, long value) {
99 throw new UnsupportedOperationException();
100 }
101
102 public void setHeader(String name, String value) {
103 throw new UnsupportedOperationException();
104 }
105
106 public void setIntHeader(String name, int value) {
107 throw new UnsupportedOperationException();
108 }
109
110 public void setStatus(int status) {
111 throw new UnsupportedOperationException();
112 }
113
114 public void setStatus(int status, String message) {
115 throw new UnsupportedOperationException();
116 }
117
118
119 public void flushBuffer() {
120 throw new UnsupportedOperationException();
121 }
122
123 public int getBufferSize() {
124 throw new UnsupportedOperationException();
125 }
126
127 public String getCharacterEncoding() {
128 throw new UnsupportedOperationException();
129 }
130
131 public Locale getLocale() {
132 throw new UnsupportedOperationException();
133 }
134
135 public ServletOutputStream getOutputStream()
136 throws IOException {
137 throw new UnsupportedOperationException();
138 }
139
140 public PrintWriter getWriter()
141 throws IOException {
142 throw new UnsupportedOperationException();
143 }
144
145 public boolean isCommitted() {
146 throw new UnsupportedOperationException();
147 }
148
149 public void reset() {
150 throw new UnsupportedOperationException();
151 }
152
153 public void resetBuffer() {
154 throw new UnsupportedOperationException();
155 }
156
157 public void setBufferSize(int size) {
158 throw new UnsupportedOperationException();
159 }
160
161 public void setContentLength(int length) {
162 throw new UnsupportedOperationException();
163 }
164
165 public void setContentType(String type) {
166 throw new UnsupportedOperationException();
167 }
168
169 public void setLocale(Locale locale) {
170 throw new UnsupportedOperationException();
171 }
172 }