CommonsValidatorEx extends Validator { @Override public ValidatorResults validate() throws ValidatorException { try { return super.validate(); } catch (ValidatorException e) { validatorException = e; throw e; } } CommonsValidatorEx(ValidatorResources resources, String formName); ValidatorException getValidatorException(); @Override ValidatorResults validate(); @Override void clear();  }
@Test public void testValidate01() throws Exception { CommonsValidatorEx_ValidatorResourcesStub01 resources = new CommonsValidatorEx_ValidatorResourcesStub01(); Form form = new Form(); resources.setForm(form); CommonsValidatorEx_FieldStub01 field = new CommonsValidatorEx_FieldStub01(); List<Field> lFields = new ArrayList<Field>(); lFields.add(field); ReflectionTestUtils.setField(form, "lFields", lFields); ValidatorResults validatorResults = new ValidatorResults(); Map<String, ValidatorResult> hResults = new HashMap<String, ValidatorResult>(); ValidatorResult validatorResult = new ValidatorResult(field); hResults.put("test", validatorResult); ReflectionTestUtils.setField(validatorResults, "hResults", hResults); field.validateReturn = validatorResults; CommonsValidatorEx commonsValidatorEx = new CommonsValidatorEx( resources, "formName"); ValidatorResults result = commonsValidatorEx.validate(); Map<?, ?> resultHResults = (Map<?, ?>) ReflectionTestUtils.getField(result, "hResults"); assertEquals(1, resultHResults.size()); assertSame(validatorResult, resultHResults.get("test")); }