Skip to content

Commit

Permalink
Add test for composite
Browse files Browse the repository at this point in the history
  • Loading branch information
jdillon committed Nov 9, 2013
1 parent f2cf497 commit 998b66a
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.Test;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayWithSize;
import static org.hamcrest.Matchers.is;

/**
Expand Down Expand Up @@ -69,4 +70,18 @@ public void explainThrowable4() {
log(msg);
assertThat(msg, is("java.lang.RuntimeException: foo, caused by: java.lang.Exception: bar, caused by: java.lang.Exception: baz"));
}

@Test
public void composite() {
Throwable foo = new Exception("foo");
Throwable bar = new Exception("bar");
try {
throw Throwables2.composite(new Exception("test"), foo, bar);
}
catch (Exception e) {
assertThat(e.getSuppressed(), arrayWithSize(2));
assertThat(e.getSuppressed()[0], is(foo));
assertThat(e.getSuppressed()[1], is(bar));
}
}
}

0 comments on commit 998b66a

Please sign in to comment.