Search in sources :

Example 6 with DummyValidatorContext

use of com.opensymphony.xwork2.validator.DummyValidatorContext in project struts by apache.

the class URLValidatorTest method testAcceptNullValueForMutualExclusionOfValidators.

public void testAcceptNullValueForMutualExclusionOfValidators() throws Exception {
    URLValidator validator = new URLValidator();
    validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf));
    validator.setFieldName("testingUrl1");
    validator.setValueStack(ActionContext.getContext().getValueStack());
    validator.validate(new MyObject());
    assertFalse(validator.getValidatorContext().hasErrors());
    assertFalse(validator.getValidatorContext().hasActionErrors());
    assertFalse(validator.getValidatorContext().hasActionMessages());
    assertFalse(validator.getValidatorContext().hasFieldErrors());
}
Also used : URLValidator(com.opensymphony.xwork2.validator.validators.URLValidator)

Example 7 with DummyValidatorContext

use of com.opensymphony.xwork2.validator.DummyValidatorContext in project struts by apache.

the class URLValidatorTest method testArrayOfUrls.

public void testArrayOfUrls() throws Exception {
    URLValidator validator = new URLValidator();
    validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf));
    validator.setFieldName("urls");
    validator.setValueStack(ActionContext.getContext().getValueStack());
    validator.validate(new MyObject());
    assertTrue(validator.getValidatorContext().hasErrors());
    assertFalse(validator.getValidatorContext().hasActionErrors());
    assertFalse(validator.getValidatorContext().hasActionMessages());
    assertTrue(validator.getValidatorContext().hasFieldErrors());
    assertEquals(1, validator.getValidatorContext().getFieldErrors().get("urls").size());
}
Also used : URLValidator(com.opensymphony.xwork2.validator.validators.URLValidator)

Example 8 with DummyValidatorContext

use of com.opensymphony.xwork2.validator.DummyValidatorContext in project struts by apache.

the class URLValidatorTest method testValidUrl1.

public void testValidUrl1() throws Exception {
    URLValidator validator = new URLValidator();
    validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf));
    validator.setFieldName("testingUrl4");
    validator.setValueStack(ActionContext.getContext().getValueStack());
    validator.validate(new MyObject());
    assertFalse(validator.getValidatorContext().hasErrors());
    assertFalse(validator.getValidatorContext().hasActionErrors());
    assertFalse(validator.getValidatorContext().hasActionMessages());
    assertFalse(validator.getValidatorContext().hasFieldErrors());
}
Also used : URLValidator(com.opensymphony.xwork2.validator.validators.URLValidator)

Example 9 with DummyValidatorContext

use of com.opensymphony.xwork2.validator.DummyValidatorContext in project struts by apache.

the class URLValidatorTest method testValidUrl2.

public void testValidUrl2() throws Exception {
    URLValidator validator = new URLValidator();
    validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf));
    validator.setFieldName("testingUrl5");
    validator.setValueStack(ActionContext.getContext().getValueStack());
    validator.validate(new MyObject());
    assertFalse(validator.getValidatorContext().hasErrors());
    assertFalse(validator.getValidatorContext().hasActionErrors());
    assertFalse(validator.getValidatorContext().hasActionMessages());
    assertFalse(validator.getValidatorContext().hasFieldErrors());
}
Also used : URLValidator(com.opensymphony.xwork2.validator.validators.URLValidator)

Example 10 with DummyValidatorContext

use of com.opensymphony.xwork2.validator.DummyValidatorContext in project struts by apache.

the class URLValidatorTest method testInvalidEmptyValue.

public void testInvalidEmptyValue() throws Exception {
    URLValidator validator = new URLValidator();
    validator.setValidatorContext(new DummyValidatorContext(new Object(), tpf));
    validator.setFieldName("testingUrl2");
    validator.setValueStack(ActionContext.getContext().getValueStack());
    validator.validate(new MyObject());
    assertFalse(validator.getValidatorContext().hasErrors());
    assertFalse(validator.getValidatorContext().hasActionErrors());
    assertFalse(validator.getValidatorContext().hasActionMessages());
    assertFalse(validator.getValidatorContext().hasFieldErrors());
}
Also used : URLValidator(com.opensymphony.xwork2.validator.validators.URLValidator)

Aggregations

DummyValidatorContext (com.opensymphony.xwork2.validator.DummyValidatorContext)21 ValidatorContext (com.opensymphony.xwork2.validator.ValidatorContext)17 RegexFieldValidator (com.opensymphony.xwork2.validator.validators.RegexFieldValidator)8 URLValidator (com.opensymphony.xwork2.validator.validators.URLValidator)8 List (java.util.List)6 ValueStack (com.opensymphony.xwork2.util.ValueStack)5 TextProviderFactory (com.opensymphony.xwork2.TextProviderFactory)4 AnnotationUser (com.opensymphony.xwork2.test.AnnotationUser)4 Test (org.junit.Test)3 AnnotatedTestBean (com.opensymphony.xwork2.AnnotatedTestBean)2 ValueStackFactory (com.opensymphony.xwork2.util.ValueStackFactory)1