PentahoCheckedChainedException extends Exception { public Throwable getRootCause() { Throwable aReason = this; Throwable lastReason = null; while ( ( aReason != null ) ) { lastReason = aReason; aReason = aReason.getCause(); } return lastReason; } PentahoCheckedChainedException();  PentahoCheckedChainedException( final String message );  PentahoCheckedChainedException( final String message, final Throwable reas );  PentahoCheckedChainedException( final Throwable reas ); Throwable getRootCause(); @Override synchronized void printStackTrace( final java.io.PrintWriter pw ); @Override synchronized void printStackTrace( final PrintStream ps );  }
@Test public void testContructors() { PentahoCheckedChainedException exception = new CheckedException(); assertNull( exception.getMessage() ); assertEquals( exception, exception.getRootCause() ); exception = new CheckedException( MSG ); assertEquals( MSG, exception.getMessage() ); assertEquals( exception, exception.getRootCause() ); exception = new CheckedException( CAUSE ); assertNotNull( exception.getMessage() ); assertTrue( exception.getMessage().contains( CAUSE_MSG ) ); assertEquals( CAUSE, exception.getRootCause() ); exception = new CheckedException( MSG, CAUSE ); assertEquals( MSG, exception.getMessage() ); assertEquals( CAUSE, exception.getRootCause() ); }
@Test public void testGetRootCause() { PentahoCheckedChainedException exception = new CheckedException( CAUSE ); Throwable rootCause = exception.getRootCause(); assertEquals( CAUSE, rootCause ); }