1 4 package com.tc.exception; 5 6 import org.mortbay.util.MultiException; 7 8 import junit.framework.TestCase; 9 10 public class ExceptionHelperTest extends TestCase { 11 public void test() { 12 ExceptionHelperImpl helper = new ExceptionHelperImpl(); 13 helper.addHelper(new RuntimeExceptionHelper()); 14 helper.addHelper(new MortbayMultiExceptionHelper()); 15 16 Throwable ultimateCause = new AssertionError (); 17 Exception proximateCause = new RuntimeException (ultimateCause); 18 Exception top = new TCRuntimeException(proximateCause); 19 20 check(helper, ultimateCause, proximateCause, top); 21 22 ultimateCause = new RuntimeException (); 23 proximateCause = new MultiException(); 24 ((MultiException)proximateCause).add((Exception )ultimateCause); 25 top = new RuntimeException (proximateCause); 26 check(helper, ultimateCause, proximateCause, top); 27 } 28 29 private void check(ExceptionHelper helper, Throwable ultimateCause, Exception proximateCause, Exception top) { 30 assertSame(ultimateCause, helper.getUltimateCause(top)); 31 assertSame(ultimateCause, helper.getUltimateCause(proximateCause)); 32 assertSame(ultimateCause, helper.getUltimateCause(ultimateCause)); 33 assertSame(proximateCause, helper.getProximateCause(top)); 34 assertSame(ultimateCause, helper.getProximateCause(proximateCause)); 35 assertSame(ultimateCause, helper.getProximateCause(ultimateCause)); 36 } 37 } 38 | Popular Tags |