List of usage examples for org.apache.commons.validator ValidatorException getMessage
public String getMessage()
From source file:jp.terasoluna.fw.validation.FieldChecksTest06.java
/** * testValidateNumber05() <br>//w w w . j a v a 2s . com * <br> * () <br> * G <br> * <br> * () bean:"5"<br> * () va:not null<br> * () field:var:<br> * integerLength="abc"<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - integerLength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - integerLength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?integerLength??????????ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateNumber05() throws Exception { // ?? // bean : "5" Object bean = "5"; // va : not null ValidatorAction va = new ValidatorAction(); // field : var:integerLength="abc" Field field = new Field(); Var var = new Var(); var.setName("integerLength"); var.setValue("abc"); field.addVar(var); // errors : not null FieldChecks_ValidationErrorsImpl01 errors = new FieldChecks_ValidationErrorsImpl01(); try { // new FieldChecks().validateNumber(bean, va, field, errors); fail(); } catch (ValidatorException e) { // String message = "Mistake on validation definition file. " + "- integerLength is not number. " + "You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest08.java
/** * testValidateArrayRange01() <br> * <br>//from www .j a v a2s. c om * () <br> * C,F,G <br> * <br> * () bean:null<br> * () va:not null<br> * () field:property="field"<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "target of validateArrayRange must be not null."<br> * () :<br> * "target of validateArrayRange must be not null."<br> * <br> * ?bean?null???ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateArrayRange01() throws Exception { // ?? field.setProperty("field"); // // try { new FieldChecks().validateArrayRange(null, va, field, errors); fail(); } catch (ValidatorException e) { String message = "target of validateArrayRange must be not null."; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error(message)))); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest05.java
/** * testValidateMaxLength03() <br>/*from w w w. j a v a2 s . c o m*/ * <br> * () <br> * F,G <br> * <br> * () bean:"test"<br> * () va:not null<br> * () field:var:<br> * maxlength=null<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - maxlength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - maxlength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?maxlength?null???ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateMaxLength03() throws Exception { // // try { new FieldChecks().validateMaxLength("test", va, field, errors); fail(); } catch (ValidatorException e) { String message = "Mistake on validation definition file. " + "- maxlength is not number. You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest05.java
/** * testValidateMinLength03() <br>/*from w w w. ja v a 2 s. c om*/ * <br> * () <br> * F,G <br> * <br> * () bean:"test"<br> * () va:not null<br> * () field:var:<br> * minlength=null<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - minlength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - minlength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?minlength?null???ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateMinLength03() throws Exception { // // try { new FieldChecks().validateMinLength("test", va, field, errors); fail(); } catch (ValidatorException e) { String message = "Mistake on validation definition file. " + "- minlength is not number. You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest08.java
/** * testValidateArrayRange04() <br> * <br>/*from w w w .j av a 2 s . co m*/ * () <br> * F,G <br> * <br> * () bean:JavaBean<br> * () va:not null<br> * () field:property=""<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Cannot get property type[" + JavaBean.class.getName+".testField]"<br> * () :ValidatorException<br> * "Cannot get property type[" + JavaBean.class.getName+".testField]"<br> * <br> * field?property???? ValidatorException??????<br> * BeanUtil.getPropertyType?null?? <br> * @throws Exception ????? */ @Test public void testValidateArrayRange04() throws Exception { // ?? FieldChecks_JavaBeanStub01 bean = new FieldChecks_JavaBeanStub01(); field.setProperty(""); // // try { new FieldChecks().validateArrayRange(bean, va, field, errors); fail(); } catch (ValidatorException e) { String message = "Cannot get property type[" + bean.getClass().getName() + ".]"; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error(message)))); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest05.java
/** * testValidateMaxLength04() <br>//w ww .ja v a2s .c om * <br> * () <br> * F,G <br> * <br> * () bean:"test"<br> * () va:not null<br> * () field:var:<br> * maxlength=""<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - maxlength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - maxlength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?maxlength????ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateMaxLength04() throws Exception { // ?? Var var = new Var(); var.setName("maxlength"); var.setValue(""); field.addVar(var); // // try { new FieldChecks().validateMaxLength("test", va, field, errors); fail(); } catch (ValidatorException e) { String message = "Mistake on validation definition file. " + "- maxlength is not number. You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest05.java
/** * testValidateMaxLength05() <br>// ww w.j a va 2s .c o m * <br> * () <br> * F,G <br> * <br> * () bean:"test"<br> * () va:not null<br> * () field:var:<br> * maxlength="abc"<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - maxlength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - maxlength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?maxlength??????????ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateMaxLength05() throws Exception { // ?? Var var = new Var(); var.setName("maxlength"); var.setValue("abc"); field.addVar(var); // // try { new FieldChecks().validateMaxLength("test", va, field, errors); fail(); } catch (ValidatorException e) { String message = "Mistake on validation definition file. " + "- maxlength is not number. You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest05.java
/** * testValidateMinLength04() <br>/* www .j a va 2 s .c o m*/ * <br> * () <br> * F,G <br> * <br> * () bean:"test"<br> * () va:not null<br> * () field:var:<br> * minlength=""<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - minlength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - minlength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?minlength????ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateMinLength04() throws Exception { // ?? Var var = new Var(); var.setName("minlength"); var.setValue(""); field.addVar(var); // // try { new FieldChecks().validateMinLength("test", va, field, errors); fail(); } catch (ValidatorException e) { String message = "Mistake on validation definition file. " + "- minlength is not number. You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest05.java
/** * testValidateMinLength05() <br>//from ww w . ja v a2s. c o m * <br> * () <br> * F,G <br> * <br> * () bean:"test"<br> * () va:not null<br> * () field:var:<br> * minlength="abc"<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Mistake on validation definition file. - minlength is not number. You'll have to check it over. "<br> * () :<br> * "Mistake on validation definition file. - minlength is not number. You'll have to check it over. ", new * NumberFormatException()<br> * <br> * var?minlength??????????ValidatorException?????? <br> * @throws Exception ????? */ @Test public void testValidateMinLength05() throws Exception { // ?? Var var = new Var(); var.setName("minlength"); var.setValue("abc"); field.addVar(var); // // try { new FieldChecks().validateMinLength("test", va, field, errors); fail(); } catch (ValidatorException e) { String message = "Mistake on validation definition file. " + "- minlength is not number. You'll have to check it over. "; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(NumberFormatException.class)); } }
From source file:jp.terasoluna.fw.validation.FieldChecksTest08.java
/** * testValidateArrayRange03() <br> * <br>/*from ww w . ja va 2 s. c o m*/ * () <br> * F <br> * <br> * () bean:JavaBean<br> * () va:not null<br> * () field:property=null<br> * () errors:not null<br> * <br> * () :ValidatorException<br> * "Cannot get property type[" + JavaBean.class.getName+".null]"<br> * () :ValidatorException<br> * "Cannot get property type[" + JavaBean.class.getName+".null]", new PropertyAccessException(new * IllegalArgumentException())<br> * <br> * field?property?null??? ValidatorException??????<br> * BeanUtil.getPropertyType?PropertyAccessException? <br> * @throws Exception ????? */ @Test public void testValidateArrayRange03() throws Exception { // ?? FieldChecks_JavaBeanStub01 bean = new FieldChecks_JavaBeanStub01(); // // try { new FieldChecks().validateArrayRange(bean, va, field, errors); fail(); } catch (ValidatorException e) { String message = "Cannot get property type[" + bean.getClass().getName() + ".null]"; assertEquals(message, e.getMessage()); assertThat(logger.getLoggingEvents().get(0).getMessage(), is(equalTo(message))); assertThat(logger.getLoggingEvents().get(0).getThrowable().get(), instanceOf(PropertyAccessException.class)); assertThat(logger.getLoggingEvents().get(0).getThrowable().get().getCause(), instanceOf(IllegalArgumentException.class)); } }