01: /*
02: * ========================================================================
03: *
04: * Copyright 2001-2003 The Apache Software Foundation.
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: *
18: * ========================================================================
19: */
20: package org.apache.cactus.sample.servlet.unit;
21:
22: import org.apache.cactus.ServletTestCase;
23:
24: import junit.framework.AssertionFailedError;
25:
26: /**
27: * Test that <code>tearDown()</code> is called even when an exception
28: * occurs during the test.
29: *
30: * @version $Id: TestTearDownException.java 238816 2004-02-29 16:36:46Z vmassol $
31: */
32: public class TestTearDownException extends ServletTestCase {
33: /**
34: * Intercepts running test cases to check for normal exceptions.
35: */
36: public void runBare() {
37: try {
38: super .runBare();
39: } catch (Throwable e) {
40: assertEquals("testTearDown() worked", e.getMessage());
41: }
42: }
43:
44: //-------------------------------------------------------------------------
45:
46: /**
47: * Verify that the <code>tearDown()</code> is always called even when there
48: * is an exception raised during the test.
49: *
50: * @exception Exception on test failure
51: */
52: public void testTearDown() throws Exception {
53: // Provoke an exception
54: fail("provoked error");
55: }
56:
57: /**
58: * Verify that the <code>tearDown()</code> is always called even when there
59: * is an exception raised during the test.
60: */
61: public void tearDown() {
62: throw new AssertionFailedError("testTearDown() worked");
63: }
64: }
|