BeanValidator { public <T> void validateOnly(T bean, String ... fieldNames) throws ValidationException { validateInternally(bean, false, 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 testValidateOnly() { IntegerBean bean = new IntegerBean(); bean.minValue = 1; bean.maxValue = 9; try { validator.validateOnly(bean, "minValue", "maxValue"); } catch (ValidationException ex) { fail("Validate only should work here."); } bean.maxValue = 11; try { validator.validateOnly(bean, "minValue", "maxValue"); fail("Validate only should fail here."); } catch (ValidationException ex) { } try { validator.validateOnly(bean, "minValue"); } catch (ValidationException ex) { fail("Validate only should not fail here."); } }