@Test
  public void settingInaccessibleFieldBypassingProtection() throws Exception {
    WithInaccessibleField target = new WithInaccessibleField();

    setField(target.getClass().getDeclaredField("i"), target, 3, true);

    assertEquals(3, target.i);
  }
  @Test
  public void settingFieldWithoutBypassingProtection() throws Exception {
    WithAccessibleField target = new WithAccessibleField();

    setField(target.getClass().getField("i"), target, 2, false);

    assertEquals(2, target.i);
  }
  @Test
  public void settingInaccessibleFieldWithoutBypassingProtection() throws Exception {
    WithInaccessibleField target = new WithInaccessibleField();

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

    setField(target.getClass().getDeclaredField("i"), target, 4, false);
  }