01: package com.mockrunner.test.web;
02:
03: import javax.servlet.jsp.tagext.TryCatchFinally;
04:
05: public class ExceptionTestTag extends TestBodyTag implements
06: TryCatchFinally {
07: private boolean doCatchCalled = false;
08: private boolean doFinallyCalled = false;
09: private Throwable caughtException = null;
10: private Throwable throwException = null;
11:
12: public ExceptionTestTag() {
13: throwException = null;
14: }
15:
16: public ExceptionTestTag(Throwable throwException) {
17: this .throwException = throwException;
18: }
19:
20: public Throwable getCaughtException() {
21: return caughtException;
22: }
23:
24: public boolean wasDoCatchCalled() {
25: return doCatchCalled;
26: }
27:
28: public boolean wasDoFinallyCalled() {
29: return doFinallyCalled;
30: }
31:
32: public void doCatch(Throwable exc) throws Throwable {
33: doCatchCalled = true;
34: caughtException = exc;
35: if (null != throwException) {
36: throw throwException;
37: }
38: }
39:
40: public void doFinally() {
41: doFinallyCalled = true;
42: if (null != throwException
43: && throwException instanceof RuntimeException) {
44: throw ((RuntimeException) throwException);
45: }
46: }
47: }
|