コード例 #1
0
  @Test
  public void invokingMethodQuietlyPropagatesExceptionRaisedByMethod() {
    thrown.expect(ReflectionException.class);
    thrown.expectMessage(NumberFormatException.class.getName());

    invoke(findMethod(getClass(), "bar"), this);
  }
コード例 #2
0
  @Test
  public void invokingMethodQuietlyWrapsIllegalAccessException() throws Exception {
    Method method = ZeroArgIllegalAccessProblematic.class.getDeclaredMethod("foo");

    thrown.expect(ReflectionException.class);
    thrown.expectMessage(IllegalAccessException.class.getName());

    invoke(method, new ZeroArgIllegalAccessProblematic(0));
  }
コード例 #3
0
  @Test
  public void invokingMethodQuietlyPropagatesOtherRuntimeExceptions() throws Exception {
    thrown.expect(NullPointerException.class);

    invoke(findMethod(getClass(), "bar"), null);
  }
コード例 #4
0
  @Test
  public void invokingMethodPropagatesIllegalArgumentException() {
    thrown.expect(IllegalArgumentException.class);

    invoke(findMethod(getClass(), "bar"), this, "baz");
  }