1 package com.sri.emo.test; 2 3 import junit.framework.TestCase; 4 5 /*** 6 * Default test case that helps deal with all the monotonous exception 7 * testing, where coverage tests complain that you haven't done it 8 * otherwise. 9 * <p/> 10 * Set the Exception, the cause, and the message, and call the super() method. 11 * 12 * @author Michael Rimov 13 * 14 */ 15 public class ExceptionTestCase extends TestCase { 16 17 protected Throwable theException; 18 19 protected Throwable cause; 20 21 protected String message; 22 23 public ExceptionTestCase() { 24 super(); 25 } 26 27 28 public void testDefaultConstructor() { 29 assert theException != null; 30 assertTrue(theException.getCause() == null); 31 assertTrue(theException.getMessage() == null); 32 } 33 34 public void testMessageConstructor() { 35 assert theException != null; 36 assertTrue(theException.getCause() == null); 37 assertTrue(theException.getMessage() == message); 38 } 39 40 public void testWrappedExceptionConstructor() { 41 assert theException != null; 42 assertTrue(theException.getCause() == cause); 43 assertTrue(theException.getMessage() == null); 44 } 45 46 public void testCombinedExceptionConstructor() { 47 assert theException != null; 48 assertTrue(theException.getCause() == cause); 49 assertTrue(theException.getMessage() == message); 50 } 51 52 protected void setUp() throws Exception { 53 theException = null; 54 cause = new IllegalArgumentException("This is a test"); 55 message = "Test Exception!"; 56 } 57 58 protected void tearDown() throws Exception { 59 theException = null; 60 cause = null; 61 message = null; 62 } 63 64 }