Search in sources :

Example 1 with RegexpURLValidator

use of org.hibernate.validator.constraintvalidators.RegexpURLValidator in project hibernate-validator by hibernate.

the class URLValidatorTest method setUp.

@BeforeMethod
public void setUp() {
    descriptorBuilder = new ConstraintAnnotationDescriptor.Builder<URL>(URL.class);
    urlValidator = new URLValidator();
    regexpURLValidator = new RegexpURLValidator();
}
Also used : ConstraintAnnotationDescriptor(org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor) URLValidator(org.hibernate.validator.internal.constraintvalidators.hv.URLValidator) RegexpURLValidator(org.hibernate.validator.constraintvalidators.RegexpURLValidator) RegexpURLValidator(org.hibernate.validator.constraintvalidators.RegexpURLValidator) URL(org.hibernate.validator.constraints.URL) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with RegexpURLValidator

use of org.hibernate.validator.constraintvalidators.RegexpURLValidator in project hibernate-validator by hibernate.

the class URLValidatorTest method protocol_host_and_port_can_be_verified_explicitly.

@Test
public void protocol_host_and_port_can_be_verified_explicitly() {
    descriptorBuilder.setAttribute("protocol", "http");
    descriptorBuilder.setAttribute("host", "www.hibernate.org");
    descriptorBuilder.setAttribute("port", 80);
    URL url = descriptorBuilder.build().getAnnotation();
    URLValidator validator = new URLValidator();
    validator.initialize(url);
    urlValidator.initialize(url);
    assertProtocolHostAnsPortMatch(urlValidator);
    regexpURLValidator.initialize(url);
    assertProtocolHostAnsPortMatch(regexpURLValidator);
}
Also used : URLValidator(org.hibernate.validator.internal.constraintvalidators.hv.URLValidator) RegexpURLValidator(org.hibernate.validator.constraintvalidators.RegexpURLValidator) URL(org.hibernate.validator.constraints.URL) Test(org.testng.annotations.Test)

Aggregations

URL (org.hibernate.validator.constraints.URL)2 RegexpURLValidator (org.hibernate.validator.constraintvalidators.RegexpURLValidator)2 URLValidator (org.hibernate.validator.internal.constraintvalidators.hv.URLValidator)2 ConstraintAnnotationDescriptor (org.hibernate.validator.internal.util.annotation.ConstraintAnnotationDescriptor)1 BeforeMethod (org.testng.annotations.BeforeMethod)1 Test (org.testng.annotations.Test)1