ExceptionHandler { public void throwMojoFailureException() throws MojoFailureException { if (fex.getCause() != null) { throw new MojoFailureException(fex.getMessage(), fex.getCause()); } else { throw new MojoFailureException(fex.getMessage()); } } ExceptionHandler(FailureException fex); void throwMojoFailureException();  }
@Test public void failureExceptionShouldThrowMojoFailureException() throws MojoFailureException { FailureException failureException = new FailureException("Gurka"); expectedException.expect(MojoFailureException.class); expectedException.expectMessage("Gurka"); new ExceptionHandler(failureException).throwMojoFailureException(); }
@Test public void failureExceptionShouldKeepCause() throws MojoFailureException { IllegalArgumentException cause = new IllegalArgumentException("not valid"); FailureException failureException = new FailureException("Gurka", cause); expectedException.expect(MojoFailureException.class); expectedException.expectMessage("Gurka"); expectedException.expectCause(is(cause)); new ExceptionHandler(failureException).throwMojoFailureException(); }