public void testGetCausalChain() { SomeUncheckedException sue = new SomeUncheckedException(); IllegalArgumentException iae = new IllegalArgumentException(sue); RuntimeException re = new RuntimeException(iae); IllegalStateException ex = new IllegalStateException(re); assertEquals(asList(ex, re, iae, sue), Throwables.getCausalChain(ex)); assertSame(sue, Iterables.getOnlyElement(Throwables.getCausalChain(sue))); List<Throwable> causes = Throwables.getCausalChain(ex); try { causes.add(new RuntimeException()); fail("List should be unmodifiable"); } catch (UnsupportedOperationException expected) { } }
public void testThrowIfUnchecked_Unchecked() { try { throwIfUnchecked(new SomeUncheckedException()); fail(); } catch (SomeUncheckedException expected) { } }
public void testGetCausalChain() { SomeUncheckedException sue = new SomeUncheckedException(); IllegalArgumentException iae = new IllegalArgumentException(sue); RuntimeException re = new RuntimeException(iae); IllegalStateException ex = new IllegalStateException(re); assertEquals(asList(ex, re, iae, sue), Throwables.getCausalChain(ex)); assertSame(sue, Iterables.getOnlyElement(Throwables.getCausalChain(sue))); List<Throwable> causes = Throwables.getCausalChain(ex); try { causes.add(new RuntimeException()); fail("List should be unmodifiable"); } catch (UnsupportedOperationException expected) { } }
static void methodThatThrowsUnchecked() { throw new SomeUncheckedException(); } static void methodThatThrowsChecked() throws SomeCheckedException {
@GwtIncompatible // throwIfInstanceOf public void testThrowIfInstanceOf_Unchecked() throws SomeCheckedException { throwIfInstanceOf(new SomeUncheckedException(), SomeCheckedException.class); }
public void testThrowIfUnchecked_Unchecked() { try { throwIfUnchecked(new SomeUncheckedException()); fail(); } catch (SomeUncheckedException expected) { } }
static void methodThatThrowsUnchecked() { throw new SomeUncheckedException(); }
@GwtIncompatible // throwIfInstanceOf public void testThrowIfInstanceOf_Unchecked() throws SomeCheckedException { throwIfInstanceOf(new SomeUncheckedException(), SomeCheckedException.class); }