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)); }
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 testGetRootCause_DoubleWrapped() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException exception = new SomeChainingException(new SomeChainingException(cause)); assertSame(cause, Throwables.getRootCause(exception)); }
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)); }
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 testGetRootCause_DoubleWrapped() { SomeCheckedException cause = new SomeCheckedException(); SomeChainingException exception = new SomeChainingException(new SomeChainingException(cause)); assertSame(cause, Throwables.getRootCause(exception)); }