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

    instantiate(ZeroArgIllegalAccessProblematic.class);
  }
コード例 #2
0
  @Test
  public void invokingNonZeroArgConstructorQuietlyPropagatesIllegalArgumentException()
      throws Exception {
    thrown.expect(IllegalArgumentException.class);

    instantiate(Integer.class.getDeclaredConstructor(int.class), "2");
  }
コード例 #3
0
  @Test
  public void invokingNonZeroArgConstructorWrapsExceptionsRaisedByConstructor() throws Exception {
    thrown.expect(ReflectionException.class);
    thrown.expectMessage(IndexOutOfBoundsException.class.getName());

    instantiate(InvocationTargetProblematic.class.getConstructor(int.class), 2);
  }
コード例 #4
0
  @Test
  public void invokingNonZeroArgConstructorQuietlyWrapsIllegalAccessException() throws Exception {
    thrown.expect(ReflectionException.class);
    thrown.expectMessage(IllegalAccessException.class.getName());

    instantiate(MultiArgIllegalAccessProblematic.class.getDeclaredConstructor(int.class), 2);
  }
コード例 #5
0
  @Test
  public void invokingZeroArgConstructorPropagatesExceptionsRaisedByConstructor() {
    thrown.expect(IllegalStateException.class);

    instantiate(InvocationTargetProblematic.class);
  }