1 package org.apache.torque; 2 3 import java.io.PrintWriter; 4 import java.io.StringWriter; 5 6 /*** 7 * Tests the class TorqueRuntimeException 8 */ 9 public class TorqueRuntimeExceptionTest extends BaseTestCase 10 { 11 /*** 12 * Creates a new instance. 13 * 14 * @param name the name of the test case. 15 */ 16 public TorqueRuntimeExceptionTest(String name) 17 { 18 super(name); 19 } 20 21 /*** 22 * Tests whether printstackTrace works. 23 */ 24 public void testPrintStackTrace() 25 { 26 StringWriter stringWriter = new StringWriter(); 27 PrintWriter writer = new PrintWriter(stringWriter); 28 try 29 { 30 throw new TorqueRuntimeException(); 31 } 32 catch (TorqueRuntimeException e) 33 { 34 e.printStackTrace(writer); 35 assertTrue(stringWriter.toString().startsWith( 36 "org.apache.torque.TorqueRuntimeException")); 37 assertTrue(stringWriter.toString().indexOf( 38 "org.apache.torque.TorqueRuntimeExceptionTest.testPrintStackTrace") 39 > 0); 40 } 41 42 } 43 }