org.springframework.validation.DataBinder.getBindingResult()

Here are the examples of the java api org.springframework.validation.DataBinder.getBindingResult() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

201 Examples 7

18 Source : ErrorsMethodArgumentResolverTests.java
with MIT License
from Vip-Augus

private BindingResult createBindingResult(Foo target, String name) {
    DataBinder binder = this.bindingContext.createDataBinder(this.exchange, target, name);
    return binder.getBindingResult();
}

16 Source : BindTagTests.java
with MIT License
from Vip-Augus

@Test
public void bindTagWithIndexedPropertiesAndCustomEditor() throws JspException {
    PageContext pc = createPageContext();
    IndexedTestBean tb = new IndexedTestBean();
    DataBinder binder = new ServletRequestDataBinder(tb, "tb");
    binder.registerCustomEditor(TestBean.clreplaced, null, new PropertyEditorSupport() {

        @Override
        public String getAsText() {
            return "something";
        }
    });
    Errors errors = binder.getBindingResult();
    errors.rejectValue("array[0]", "code1", "message1");
    errors.rejectValue("array[0]", "code2", "message2");
    pc.getRequest().setAttribute(BindingResult.MODEL_KEY_PREFIX + "tb", errors);
    BindTag tag = new BindTag();
    tag.setPageContext(pc);
    tag.setPath("tb.array[0]");
    replacedertTrue("Correct doStartTag return value", tag.doStartTag() == Tag.EVAL_BODY_INCLUDE);
    BindStatus status = (BindStatus) pc.getAttribute(BindTag.STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
    replacedertTrue("Has status variable", status != null);
    replacedertTrue("Correct expression", "array[0]".equals(status.getExpression()));
    // because of the custom editor getValue() should return a String
    replacedertTrue("Value is TestBean", status.getValue() instanceof String);
    replacedertTrue("Correct value", "something".equals(status.getValue()));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testPatternArrayFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("patternArray", new String[] { "1,25.00", "2,35.00" });
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00", binder.getBindingResult().getFieldValue("patternArray[0]"));
    replacedertEquals("2,35.00", binder.getBindingResult().getFieldValue("patternArray[1]"));
    propertyValues = new MutablePropertyValues();
    propertyValues.add("patternArray[0]", "1,25.00");
    propertyValues.add("patternArray[1]", "2,35.00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00", binder.getBindingResult().getFieldValue("patternArray[0]"));
    replacedertEquals("2,35.00", binder.getBindingResult().getFieldValue("patternArray[1]"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testPatternFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("pattern", "1,25.00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00", binder.getBindingResult().getFieldValue("pattern"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testPercentFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("percent", "53%");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("53%", binder.getBindingResult().getFieldValue("percent"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testPatternList2FormattingListElement() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("patternList2[0]", "1,25.00");
    propertyValues.add("patternList2[1]", "2,35.00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00", binder.getBindingResult().getFieldValue("patternList2[0]"));
    replacedertEquals("2,35.00", binder.getBindingResult().getFieldValue("patternList2[1]"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testDefaultNumberFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("numberDefault", "3,339.12");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("3,339", binder.getBindingResult().getFieldValue("numberDefault"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testPatternList2FormattingList() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("patternList2[0]", "1,25.00");
    propertyValues.add("patternList2[1]", "2,35.00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00,2,35.00", binder.getBindingResult().getFieldValue("patternList2"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testCurrencyFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("currency", "$3,339.12");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("$3,339.12", binder.getBindingResult().getFieldValue("currency"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testDefaultNumberFormattingAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("numberDefaultAnnotated", "3,339.12");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("3,339.12", binder.getBindingResult().getFieldValue("numberDefaultAnnotated"));
}

16 Source : NumberFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testPatternListFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("patternList", new String[] { "1,25.00", "2,35.00" });
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00", binder.getBindingResult().getFieldValue("patternList[0]"));
    replacedertEquals("2,35.00", binder.getBindingResult().getFieldValue("patternList[1]"));
    propertyValues = new MutablePropertyValues();
    propertyValues.add("patternList[0]", "1,25.00");
    propertyValues.add("patternList[1]", "2,35.00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("1,25.00", binder.getBindingResult().getFieldValue("patternList[0]"));
    replacedertEquals("2,35.00", binder.getBindingResult().getFieldValue("patternList[1]"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindInstant() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("instant", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31T12:00"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindDateTimeAnnotatedPattern() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotatedPattern", "10/31/09 12:00 PM");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("10/31/09 12:00 PM", binder.getBindingResult().getFieldValue("dateTimeAnnotatedPattern"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindYear() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("year", "2007");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("year").toString().equals("2007"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISODate() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDate", "2009-10-31");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("2009-10-31", binder.getBindingResult().getFieldValue("isoDate"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindMonthInAnyCase() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("month", "July");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("month").toString().equals("JULY"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateAnnotatedWithError() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateAnnotated", "Oct -31, 2009");
    binder.bind(propertyValues);
    replacedertEquals(1, binder.getBindingResult().getFieldErrorCount("localDateAnnotated"));
    replacedertEquals("Oct -31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindDuration() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("duration", "PT8H6M12.345S");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("duration").toString().equals("PT8H6M12.345S"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindNestedLocalDateAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("children[0].localDateAnnotated", "Oct 31, 2009");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("children[0].localDateAnnotated"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateTimeFromJavaUtilCalendar() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", new GregorianCalendar(2009, 9, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertTrue(value.startsWith("10/31/09"));
    replacedertTrue(value.endsWith("12:00 PM"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateArray() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", new String[] { "10/31/09" });
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateAnnotated", "Oct 31, 2009");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("Oct 31, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISOTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoTime", "12:00:00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00:00", binder.getBindingResult().getFieldValue("isoTime"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindMonthDay() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("monthDay", "--12-03");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("monthDay").toString().equals("--12-03"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDate() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "10/31/09");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("10/31/09", binder.getBindingResult().getFieldValue("localDate"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindMonth() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("month", "JULY");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("month").toString().equals("JULY"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISODateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDateTime", "2009-10-31T12:00:00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("2009-10-31T12:00:00", binder.getBindingResult().getFieldValue("isoDateTime"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISOTimeWithZone() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoTime", "12:00:00.000-05:00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00:00", binder.getBindingResult().getFieldValue("isoTime"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindDateTimeOverflow() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotatedPattern", "02/29/09 12:00 PM");
    binder.bind(propertyValues);
    replacedertEquals(1, binder.getBindingResult().getErrorCount());
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertTrue(value.startsWith("10/31/09"));
    replacedertTrue(value.endsWith("12:00 PM"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindPeriod() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("period", "P6Y3M1D");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("period").toString().equals("P6Y3M1D"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTimeAnnotated", LocalDateTime.of(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("localDateTimeAnnotated").toString();
    replacedertTrue(value.startsWith("Oct 31, 2009"));
    replacedertTrue(value.endsWith("12:00:00 PM"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindYearMonth() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("yearMonth", "2007-12");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("yearMonth").toString().equals("2007-12"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTime", "12:00 PM");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00 PM", binder.getBindingResult().getFieldValue("localTime"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalTimeFromJavaUtilCalendar() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTime", new GregorianCalendar(1970, 0, 0, 12, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00 PM", binder.getBindingResult().getFieldValue("localTime"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTimeAnnotated", "12:00:00 PM");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00:00 PM", binder.getBindingResult().getFieldValue("localTimeAnnotated"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISODateTimeWithZone() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDateTime", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("2009-10-31T12:00:00", binder.getBindingResult().getFieldValue("isoDateTime"));
}

16 Source : DateTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateFromJavaUtilCalendar() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", new GregorianCalendar(2009, 9, 31, 0, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("10/31/09", binder.getBindingResult().getFieldValue("localDate"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISOTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoTime", "12:00:00.000-05:00");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00:00.000", binder.getBindingResult().getFieldValue("isoTime"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotated", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("dateTimeAnnotated").toString();
    replacedertTrue(value.startsWith("Oct 31, 2009"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalTimeWithSpecificStyle() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setTimeStyle("M");
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTime", "12:00:00 PM");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("12:00:00 PM", binder.getBindingResult().getFieldValue("localTime"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindDuration() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("duration", "PT72.345S");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertTrue(binder.getBindingResult().getFieldValue("duration").toString().equals("PT72.345S"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", new LocalDateTime(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertTrue(value.startsWith("10/31/09"));
    replacedertTrue(value.endsWith("12:00 PM"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindMutableDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("mutableDateTimeAnnotated", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("2009-10-31T07:00:00.000-05:00", binder.getBindingResult().getFieldValue("mutableDateTimeAnnotated"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTimeAnnotated", new LocalDateTime(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("localDateTimeAnnotated").toString();
    replacedertTrue(value.startsWith("Oct 31, 2009"));
    replacedertTrue(value.endsWith("12:00 PM"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindISODateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDateTime", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("2009-10-31T07:00:00.000-05:00", binder.getBindingResult().getFieldValue("isoDateTime"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateAnnotatedWithError() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateAnnotated", "Oct 031, 2009");
    binder.bind(propertyValues);
    replacedertEquals(1, binder.getBindingResult().getFieldErrorCount("localDateAnnotated"));
    replacedertEquals("Oct 031, 2009", binder.getBindingResult().getFieldValue("localDateAnnotated"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindDateTimeAnnotatedDefault() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotatedDefault", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    String value = binder.getBindingResult().getFieldValue("dateTimeAnnotatedDefault").toString();
    replacedertTrue(value.startsWith("10/31/09"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindLocalDateWithSpecificFormatter() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setDateFormatter(org.joda.time.format.DateTimeFormat.forPattern("yyyyMMdd"));
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "20091031");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("20091031", binder.getBindingResult().getFieldValue("localDate"));
}

16 Source : JodaTimeFormattingTests.java
with MIT License
from Vip-Augus

@Test
public void testBindInstantAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("instantAnnotated", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertEquals(0, binder.getBindingResult().getErrorCount());
    replacedertEquals("2009-10-31T07:00:00.000-05:00", binder.getBindingResult().getFieldValue("instantAnnotated"));
}

See More Examples