@SuppressWarnings("ThrowIfUncheckedKnownChecked") public void testThrowIfUnchecked_Checked() { throwIfUnchecked(new SomeCheckedException()); }
public void testGetRootCause_NoCause() { SomeCheckedException exception = new SomeCheckedException(); assertSame(exception, Throwables.getRootCause(exception)); }
public void testGetRootCause_SingleWrapped() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException exception = new SomeChainingException(cause); assertSame(cause, Throwables.getRootCause(exception)); }
@GwtIncompatible // Throwables.getCauseAs(Throwable, Class) public void testGetCauseAs() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException thrown = new SomeChainingException(cause); assertThat(thrown.getCause()).isSameAs(cause); assertThat(Throwables.getCauseAs(thrown, SomeCheckedException.class)).isSameAs(cause); assertThat(Throwables.getCauseAs(thrown, Exception.class)).isSameAs(cause); try { Throwables.getCauseAs(thrown, IllegalStateException.class); fail("Should have thrown CCE"); } catch (ClassCastException expected) { assertThat(expected.getCause()).isSameAs(thrown); } }
public void testGetRootCause_NoCause() { SomeCheckedException exception = new SomeCheckedException(); assertSame(exception, Throwables.getRootCause(exception)); }
@SuppressWarnings("ThrowIfUncheckedKnownChecked") public void testThrowIfUnchecked_Checked() { throwIfUnchecked(new SomeCheckedException()); }
static void methodThatThrowsChecked() throws SomeCheckedException { throw new SomeCheckedException(); } static void methodThatThrowsOtherChecked() throws SomeOtherCheckedException {
@GwtIncompatible // throwIfInstanceOf public void testThrowIfInstanceOf_CheckedSame() { try { throwIfInstanceOf(new SomeCheckedException(), SomeCheckedException.class); fail(); } catch (SomeCheckedException expected) { } }
public void testGetRootCause_DoubleWrapped() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException exception = new SomeChainingException(new SomeChainingException(cause)); assertSame(cause, Throwables.getRootCause(exception)); }
public void testGetRootCause_SingleWrapped() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException exception = new SomeChainingException(cause); assertSame(cause, Throwables.getRootCause(exception)); }
static void methodThatThrowsChecked() throws SomeCheckedException { throw new SomeCheckedException(); }
@GwtIncompatible // Throwables.getCauseAs(Throwable, Class) public void testGetCauseAs() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException thrown = new SomeChainingException(cause); assertThat(thrown).hasCauseThat().isSameAs(cause); assertThat(Throwables.getCauseAs(thrown, SomeCheckedException.class)).isSameAs(cause); assertThat(Throwables.getCauseAs(thrown, Exception.class)).isSameAs(cause); try { Throwables.getCauseAs(thrown, IllegalStateException.class); fail("Should have thrown CCE"); } catch (ClassCastException expected) { assertThat(expected).hasCauseThat().isSameAs(thrown); } }
@GwtIncompatible // throwIfInstanceOf public void testThrowIfInstanceOf_CheckedSame() { try { throwIfInstanceOf(new SomeCheckedException(), SomeCheckedException.class); fail(); } catch (SomeCheckedException expected) { } }
public void testGetRootCause_DoubleWrapped() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException exception = new SomeChainingException(new SomeChainingException(cause)); assertSame(cause, Throwables.getRootCause(exception)); }