BeanValidator { public <T> void validateWithout(T bean, String ... fieldNames) throws ValidationException { validateInternally(bean, true, fieldNames); } private  BeanValidator(); static BeanValidator getInstance(); void validate(T bean); void validateOnly(T bean, String ... fieldNames); void validateWithout(T bean, String ... fieldNames);  }
@Test public void testValidateWithout() { IntegerBean bean = new IntegerBean(); bean.minValue = 1; bean.maxValue = 11; try { validator.validateWithout(bean, "maxValue"); } catch (ValidationException ex) { fail("Validate without should work here."); } try { validator.validateWithout(bean, "minValue"); fail("Validate without should fail here."); } catch (ValidationException ex) { } bean.minValue = -1; bean.maxValue = 11; try { validator.validateWithout(bean, "maxValue"); fail("Validate without should fail here."); } catch (ValidationException ex) { } try { validator.validateWithout(bean, "minValue", "maxValue"); } catch (ValidationException ex) { fail("Validate without should not fail here."); } }