01: package org.apache.torque;
02:
03: import java.io.PrintWriter;
04: import java.io.StringWriter;
05:
06: /**
07: * Tests the class TorqueRuntimeException
08: */
09: public class TorqueRuntimeExceptionTest extends BaseTestCase {
10: /**
11: * Creates a new instance.
12: *
13: * @param name the name of the test case.
14: */
15: public TorqueRuntimeExceptionTest(String name) {
16: super (name);
17: }
18:
19: /**
20: * Tests whether printstackTrace works.
21: */
22: public void testPrintStackTrace() {
23: StringWriter stringWriter = new StringWriter();
24: PrintWriter writer = new PrintWriter(stringWriter);
25: try {
26: throw new TorqueRuntimeException();
27: } catch (TorqueRuntimeException e) {
28: e.printStackTrace(writer);
29: assertTrue(stringWriter.toString().startsWith(
30: "org.apache.torque.TorqueRuntimeException"));
31: assertTrue(stringWriter
32: .toString()
33: .indexOf(
34: "org.apache.torque.TorqueRuntimeExceptionTest.testPrintStackTrace") > 0);
35: }
36:
37: }
38: }
|