URLValidator extends FieldValidatorSupport { public void validate(Object object) throws ValidationException { String fieldName = getFieldName(); if (object == null || object.toString().length() == 0) { return; } if (!(object.getClass().equals(String.class)) || !URLUtil.verifyUrl((String) object)) { addFieldValidationError(fieldName, object); } }  void validate(Object object);  }
@Test public void testSuccess() { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("url", "http: try { this.validate(map); } catch (ValidationException e) { Assert.fail(e.getMessage()); } }
@Test public void testFailure() { boolean success = false; HashMap<String, Object> map = new HashMap<String, Object>(); map.put("url", "a"); try { this.validate(map); } catch (ValidationException e) { success = true; } Assert.assertTrue(success); }