org.springframework.beans.MutablePropertyValues - java examples

Here are the examples of the java api org.springframework.beans.MutablePropertyValues taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

155 Examples 7

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindInstant() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("instant", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("instant").toString().startsWith("2009-10-31T12:00")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindYearMonth() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("yearMonth", "2007-12");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("yearMonth").toString().equals("2007-12")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTimeAnnotated", new LocalDateTime(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTimeAnnotated").toString();
    replacedertThat(value.startsWith("Oct 31, 2009")).isTrue();
    replacedertThat(value.endsWith("12:00 PM")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLongAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("millisAnnotated", "10/31/09");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("millisAnnotated")).isEqualTo("10/31/09");
}

19 View Complete Implementation : WebDataBinder.java
Copyright Apache License 2.0
Author : spring-projects
/**
 * Bind all multipart files contained in the given request, if any
 * (in case of a multipart request). To be called by subclreplacedes.
 * <p>Multipart files will only be added to the property values if they
 * are not empty or if we're configured to bind empty multipart files too.
 * @param multipartFiles a Map of field name String to MultipartFile object
 * @param mpvs the property values to be bound (can be modified)
 * @see org.springframework.web.multipart.MultipartFile
 * @see #setBindEmptyMultipartFiles
 */
protected void bindMultipart(Map<String, List<MultipartFile>> multipartFiles, MutablePropertyValues mpvs) {
    multipartFiles.forEach((key, values) -> {
        if (values.size() == 1) {
            MultipartFile value = values.get(0);
            if (isBindEmptyMultipartFiles() || !value.isEmpty()) {
                mpvs.add(key, value);
            }
        } else {
            mpvs.add(key, values);
        }
    });
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateTimeFromJavaUtilCalendar() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", new GregorianCalendar(2009, 9, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertThat(value.startsWith("10/31/09")).isTrue();
    replacedertThat(value.endsWith("12:00 PM")).isTrue();
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindISODateTimeWithZone() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDateTime", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("isoDateTime")).isEqualTo("2009-10-31T12:00:00");
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTimeAnnotated", LocalDateTime.of(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTimeAnnotated").toString();
    replacedertThat(value.startsWith("Oct 31, 2009")).isTrue();
    replacedertThat(value.endsWith("12:00:00 PM")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDate() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "10/31/09");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("10/31/09");
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateWithSpecificStyle() {
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setDateStyle(FormatStyle.LONG);
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "October 31, 2009");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("October 31, 2009");
}

19 View Complete Implementation : DateFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
void testBindDateArray() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotated", new String[] { "10/31/09 12:00 PM" });
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
}

19 View Complete Implementation : DateFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
void testBindDateAnnotatedWithError() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotated", "Oct X31, 2009");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getFieldErrorCount("dateAnnotated")).isEqualTo(1);
    replacedertThat(binder.getBindingResult().getFieldValue("dateAnnotated")).isEqualTo("Oct X31, 2009");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateWithSpecificStyle() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setDateStyle("L");
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "October 31, 2009");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("October 31, 2009");
}

19 View Complete Implementation : DateFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
void testBindISOTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoTime", "12:00:00.000-05:00");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("isoTime")).isEqualTo("17:00:00.000Z");
}

19 View Complete Implementation : ServletContextSupportTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
@SuppressWarnings("resource")
public void testServletContextAttributeFactoryBeanWithAttributeNotFound() {
    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("attributeName", "myAttr");
    wac.registerSingleton("importedAttr", ServletContextAttributeFactoryBean.clreplaced, pvs);
    replacedertThatExceptionOfType(BeanCreationException.clreplaced).isThrownBy(wac::refresh).withCauseInstanceOf(IllegalStateException.clreplaced).withMessageContaining("myAttr");
}

19 View Complete Implementation : DateFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
void testBindLong() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("millis", "1256961600");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("millis")).isEqualTo("1256961600");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeWithSpecificFormatter() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setDateTimeFormatter(org.joda.time.format.DateTimeFormat.forPattern("yyyyMMddHHmmss"));
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTime", "20091031130000");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("dateTime")).isEqualTo("20091031130000");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotated", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("dateTimeAnnotated").toString();
    replacedertThat(value.startsWith("Oct 31, 2009")).isTrue();
}

19 View Complete Implementation : WebDataBinder.java
Copyright Apache License 2.0
Author : spring-projects
/**
 * This implementation performs a field default and marker check
 * before delegating to the superclreplaced binding process.
 * @see #checkFieldDefaults
 * @see #checkFieldMarkers
 */
@Override
protected void doBind(MutablePropertyValues mpvs) {
    checkFieldDefaults(mpvs);
    checkFieldMarkers(mpvs);
    super.doBind(mpvs);
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindPeriod() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("period", "P6Y3M1D");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("period").toString().equals("P6Y3M1D")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeWithSpecificStyle() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setDateTimeStyle("MM");
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", new LocalDateTime(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertThat(value.startsWith("Oct 31, 2009")).isTrue();
    replacedertThat(value.endsWith("12:00:00 PM")).isTrue();
}

19 View Complete Implementation : NumberFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testPatternListFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("patternList", new String[] { "1,25.00", "2,35.00" });
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("patternList[0]")).isEqualTo("1,25.00");
    replacedertThat(binder.getBindingResult().getFieldValue("patternList[1]")).isEqualTo("2,35.00");
    propertyValues = new MutablePropertyValues();
    propertyValues.add("patternList[0]", "1,25.00");
    propertyValues.add("patternList[1]", "2,35.00");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("patternList[0]")).isEqualTo("1,25.00");
    replacedertThat(binder.getBindingResult().getFieldValue("patternList[1]")).isEqualTo("2,35.00");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalTimeWithSpecificFormatter() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setTimeFormatter(org.joda.time.format.DateTimeFormat.forPattern("HHmmss"));
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTime", "130000");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("130000");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@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);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("20091031");
}

19 View Complete Implementation : DataBinder.java
Copyright Apache License 2.0
Author : spring-projects
/**
 * Bind the given property values to this binder's target.
 * <p>This call can create field errors, representing basic binding
 * errors like a required field (code "required"), or type mismatch
 * between value and bean property (code "typeMismatch").
 * <p>Note that the given PropertyValues should be a throwaway instance:
 * For efficiency, it will be modified to just contain allowed fields if it
 * implements the MutablePropertyValues interface; else, an internal mutable
 * copy will be created for this purpose. Preplaced in a copy of the PropertyValues
 * if you want your original instance to stay unmodified in any case.
 * @param pvs property values to bind
 * @see #doBind(org.springframework.beans.MutablePropertyValues)
 */
public void bind(PropertyValues pvs) {
    MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues ? (MutablePropertyValues) pvs : new MutablePropertyValues(pvs));
    doBind(mpvs);
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTime", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("dateTime").toString();
    replacedertThat(value.startsWith("10/31/09")).isTrue();
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeAnnotatedPattern() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotatedPattern", "10/31/09 12:00 PM");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("dateTimeAnnotatedPattern")).isEqualTo("10/31/09 12:00 PM");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", new LocalDateTime(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertThat(value.startsWith("10/31/09")).isTrue();
    replacedertThat(value.endsWith("12:00 PM")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindISODateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDateTime", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("isoDateTime")).isEqualTo("2009-10-31T07:00:00.000-05:00");
}

19 View Complete Implementation : ServletContextSupportTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
@SuppressWarnings("resource")
public void testServletContextParameterFactoryBean() {
    MockServletContext sc = new MockServletContext();
    sc.addInitParameter("myParam", "myValue");
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("initParamName", "myParam");
    wac.registerSingleton("importedParam", ServletContextParameterFactoryBean.clreplaced, pvs);
    wac.refresh();
    Object value = wac.getBean("importedParam");
    replacedertThat(value).isEqualTo("myValue");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalTimeAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTimeAnnotated", "12:00:00 PM");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localTimeAnnotated")).isEqualTo("12:00:00 PM");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeISO() {
    JodaTimeFormatterRegistrar registrar = new JodaTimeFormatterRegistrar();
    registrar.setUseIsoFormat(true);
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTime", "2009-10-31T12:00:00.000Z");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("dateTime")).isEqualTo("2009-10-31T07:00:00.000-05:00");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateArray() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", new String[] { "10/31/09" });
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
}

19 View Complete Implementation : NumberFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testPatternArrayFormatting() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("patternArray", new String[] { "1,25.00", "2,35.00" });
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("patternArray[0]")).isEqualTo("1,25.00");
    replacedertThat(binder.getBindingResult().getFieldValue("patternArray[1]")).isEqualTo("2,35.00");
    propertyValues = new MutablePropertyValues();
    propertyValues.add("patternArray[0]", "1,25.00");
    propertyValues.add("patternArray[1]", "2,35.00");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("patternArray[0]")).isEqualTo("1,25.00");
    replacedertThat(binder.getBindingResult().getFieldValue("patternArray[1]")).isEqualTo("2,35.00");
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindISODate() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("isoDate", "2009-10-31");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("isoDate")).isEqualTo("2009-10-31");
}

19 View Complete Implementation : ServletContextSupportTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
@SuppressWarnings("resource")
public void testServletContextAttributeFactoryBean() {
    MockServletContext sc = new MockServletContext();
    sc.setAttribute("myAttr", "myValue");
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("attributeName", "myAttr");
    wac.registerSingleton("importedAttr", ServletContextAttributeFactoryBean.clreplaced, pvs);
    wac.refresh();
    Object value = wac.getBean("importedAttr");
    replacedertThat(value).isEqualTo("myValue");
}

19 View Complete Implementation : DateFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
void testBindDateAnnotatedPattern() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotatedPattern", "10/31/09 1:05");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("dateAnnotatedPattern")).isEqualTo("10/31/09 1:05");
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeWithSpecificStyle() {
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setDateTimeStyle(FormatStyle.MEDIUM);
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertThat(value.startsWith("Oct 31, 2009")).isTrue();
    replacedertThat(value.endsWith("12:00:00 PM")).isTrue();
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindMonthDay() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("monthDay", "--12-03");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("monthDay").toString().equals("--12-03")).isTrue();
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateWithSpecificFormatter() {
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setDateFormatter(DateTimeFormatter.ofPattern("yyyyMMdd"));
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDate", "20091031");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localDate")).isEqualTo("20091031");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateTimeAnnotatedDefault() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateTimeAnnotatedDefault", new DateTime(2009, 10, 31, 12, 0, ISOChronology.getInstanceUTC()));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("dateTimeAnnotatedDefault").toString();
    replacedertThat(value.startsWith("10/31/09")).isTrue();
}

19 View Complete Implementation : NumberFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@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);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("patternList2[0]")).isEqualTo("1,25.00");
    replacedertThat(binder.getBindingResult().getFieldValue("patternList2[1]")).isEqualTo("2,35.00");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateAnnotated", "Oct 31, 2009");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localDateAnnotated")).isEqualTo("Oct 31, 2009");
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalTimeWithSpecificFormatter() {
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setTimeFormatter(DateTimeFormatter.ofPattern("HHmmss"));
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTime", "130000");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("130000");
}

19 View Complete Implementation : ServletContextSupportTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
@SuppressWarnings("resource")
public void testServletContextParameterFactoryBeanWithAttributeNotFound() {
    MockServletContext sc = new MockServletContext();
    StaticWebApplicationContext wac = new StaticWebApplicationContext();
    wac.setServletContext(sc);
    MutablePropertyValues pvs = new MutablePropertyValues();
    pvs.add("initParamName", "myParam");
    wac.registerSingleton("importedParam", ServletContextParameterFactoryBean.clreplaced, pvs);
    replacedertThatExceptionOfType(BeanCreationException.clreplaced).isThrownBy(wac::refresh).withCauseInstanceOf(IllegalStateException.clreplaced).withMessageContaining("myParam");
}

19 View Complete Implementation : DataBinder.java
Copyright Apache License 2.0
Author : spring-projects
/**
 * Actual implementation of the binding process, working with the
 * preplaceded-in MutablePropertyValues instance.
 * @param mpvs the property values to bind,
 * as MutablePropertyValues instance
 * @see #checkAllowedFields
 * @see #checkRequiredFields
 * @see #applyPropertyValues
 */
protected void doBind(MutablePropertyValues mpvs) {
    checkAllowedFields(mpvs);
    checkRequiredFields(mpvs);
    applyPropertyValues(mpvs);
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalDateTime() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localDateTime", LocalDateTime.of(2009, 10, 31, 12, 0));
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    String value = binder.getBindingResult().getFieldValue("localDateTime").toString();
    replacedertThat(value.startsWith("10/31/09")).isTrue();
    replacedertThat(value.endsWith("12:00 PM")).isTrue();
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@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);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00:00 PM");
}

19 View Complete Implementation : DateTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindLocalTimeWithSpecificStyle() {
    DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
    registrar.setTimeStyle(FormatStyle.MEDIUM);
    setup(registrar);
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("localTime", "12:00:00 PM");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("localTime")).isEqualTo("12:00:00 PM");
}

19 View Complete Implementation : JodaTimeFormattingTests.java
Copyright Apache License 2.0
Author : spring-projects
@Test
public void testBindDateAnnotated() {
    MutablePropertyValues propertyValues = new MutablePropertyValues();
    propertyValues.add("dateAnnotated", "10/31/09");
    binder.bind(propertyValues);
    replacedertThat(binder.getBindingResult().getErrorCount()).isEqualTo(0);
    replacedertThat(binder.getBindingResult().getFieldValue("dateAnnotated")).isEqualTo("10/31/09");
}