1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.log;
17
18 import org.apache.commons.logging.Log;
19
20 /***
21 * A Mock Object useful for unit testing of commons-logging. (Maybe this should
22 * be contributed back to commons-logging?)
23 *
24 * @author James Strachan
25 * @version 1.1 2003/01/22 10:22:30
26 */
27 public class MockLog implements Log {
28
29 private Object debug;
30 private Object trace;
31 private Object info;
32 private Object warn;
33 private Object error;
34 private Object fatal;
35 private Throwable lastThrowable;
36
37 public MockLog() {
38 }
39
40 /***
41 * Resets all the last logging messages received
42 */
43 public void clear() {
44 this.debug = null;
45 this.trace = null;
46 this.info = null;
47 this.warn = null;
48 this.error = null;
49 this.fatal = null;
50 this.lastThrowable = null;
51 }
52
53
54
55
56
57 /***
58 * @see org.apache.commons.logging.Log#debug(java.lang.Object, java.lang.Throwable)
59 */
60 public void debug(Object message, Throwable exception) {
61 this.debug = message;
62 this.lastThrowable = exception;
63 }
64
65 /***
66 * @see org.apache.commons.logging.Log#debug(java.lang.Object)
67 */
68 public void debug(Object message) {
69 this.debug = message;
70 }
71
72 /***
73 * @see org.apache.commons.logging.Log#error(java.lang.Object, java.lang.Throwable)
74 */
75 public void error(Object message, Throwable exception) {
76 this.error = message;
77 this.lastThrowable = exception;
78 }
79
80 /***
81 * @see org.apache.commons.logging.Log#error(java.lang.Object)
82 */
83 public void error(Object message) {
84 this.error = message;
85 }
86
87 /***
88 * @see org.apache.commons.logging.Log#fatal(java.lang.Object, java.lang.Throwable)
89 */
90 public void fatal(Object message, Throwable exception) {
91 this.fatal = message;
92 this.lastThrowable = exception;
93 }
94
95 /***
96 * @see org.apache.commons.logging.Log#fatal(java.lang.Object)
97 */
98 public void fatal(Object message) {
99 this.fatal = message;
100 }
101
102 /***
103 * @see org.apache.commons.logging.Log#info(java.lang.Object, java.lang.Throwable)
104 */
105 public void info(Object message, Throwable exception) {
106 this.info = message;
107 this.lastThrowable = exception;
108 }
109
110 /***
111 * @see org.apache.commons.logging.Log#info(java.lang.Object)
112 */
113 public void info(Object message) {
114 this.info = message;
115 }
116
117 /***
118 * @see org.apache.commons.logging.Log#isDebugEnabled()
119 */
120 public boolean isDebugEnabled() {
121 return true;
122 }
123
124 /***
125 * @see org.apache.commons.logging.Log#isErrorEnabled()
126 */
127 public boolean isErrorEnabled() {
128 return true;
129 }
130
131 /***
132 * @see org.apache.commons.logging.Log#isFatalEnabled()
133 */
134 public boolean isFatalEnabled() {
135 return true;
136 }
137
138 /***
139 * @see org.apache.commons.logging.Log#isInfoEnabled()
140 */
141 public boolean isInfoEnabled() {
142 return true;
143 }
144
145 /***
146 * @see org.apache.commons.logging.Log#isTraceEnabled()
147 */
148 public boolean isTraceEnabled() {
149 return true;
150 }
151
152 /***
153 * @see org.apache.commons.logging.Log#isWarnEnabled()
154 */
155 public boolean isWarnEnabled() {
156 return true;
157 }
158
159 /***
160 * @see org.apache.commons.logging.Log#trace(java.lang.Object, java.lang.Throwable)
161 */
162 public void trace(Object message, Throwable exception) {
163 this.trace = message;
164 this.lastThrowable = exception;
165 }
166
167 /***
168 * @see org.apache.commons.logging.Log#trace(java.lang.Object)
169 */
170 public void trace(Object message) {
171 this.trace = message;
172 }
173
174 /***
175 * @see org.apache.commons.logging.Log#warn(java.lang.Object, java.lang.Throwable)
176 */
177 public void warn(Object message, Throwable exception) {
178 this.warn = message;
179 }
180
181 /***
182 * @see org.apache.commons.logging.Log#warn(java.lang.Object)
183 */
184 public void warn(Object message) {
185 this.warn = message;
186 }
187
188
189
190
191 /***
192 * Returns the error.
193 * @return Object
194 */
195 public Object getError() {
196 return error;
197 }
198
199 /***
200 * Returns the fatal.
201 * @return Object
202 */
203 public Object getFatal() {
204 return fatal;
205 }
206
207 /***
208 * Returns the info.
209 * @return Object
210 */
211 public Object getInfo() {
212 return info;
213 }
214
215 /***
216 * Returns the lastThrowable.
217 * @return Throwable
218 */
219 public Throwable getLastThrowable() {
220 return lastThrowable;
221 }
222
223 /***
224 * Returns the warn.
225 * @return Object
226 */
227 public Object getWarn() {
228 return warn;
229 }
230
231 /***
232 * Returns the trace.
233 * @return Object
234 */
235 public Object getTrace() {
236 return trace;
237 }
238
239 /***
240 * Returns the debug.
241 * @return Object
242 */
243 public Object getDebug() {
244 return debug;
245 }
246
247 }