View Javadoc
1   package org.junit.internal.matchers;
2   
3   import org.junit.Test;
4   
5   import static org.hamcrest.CoreMatchers.is;
6   import static org.junit.Assert.assertThat;
7   import static org.junit.internal.matchers.ThrowableCauseMatcher.hasCause;
8   
9   public class ThrowableCauseMatcherTest {
10  
11      @Test
12      public void shouldAllowCauseOfDifferentClassFromRoot() throws Exception {
13          NullPointerException expectedCause = new NullPointerException("expected");
14          Exception actual = new Exception(expectedCause);
15  
16          assertThat(actual, hasCause(is(expectedCause)));
17      }
18  }