|
|
@ -16,6 +16,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.boot.bind;
|
|
|
|
package org.springframework.boot.bind;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.nullValue;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
|
|
|
|
|
|
|
|
|
import java.lang.annotation.Documented;
|
|
|
|
import java.lang.annotation.Documented;
|
|
|
|
import java.lang.annotation.ElementType;
|
|
|
|
import java.lang.annotation.ElementType;
|
|
|
|
import java.lang.annotation.Retention;
|
|
|
|
import java.lang.annotation.Retention;
|
|
|
@ -40,7 +48,6 @@ import javax.validation.constraints.NotNull;
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Rule;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.Test;
|
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.MutablePropertyValues;
|
|
|
|
import org.springframework.beans.MutablePropertyValues;
|
|
|
|
import org.springframework.beans.NotWritablePropertyException;
|
|
|
|
import org.springframework.beans.NotWritablePropertyException;
|
|
|
|
import org.springframework.context.support.StaticMessageSource;
|
|
|
|
import org.springframework.context.support.StaticMessageSource;
|
|
|
@ -53,14 +60,6 @@ import org.springframework.validation.DataBinder;
|
|
|
|
import org.springframework.validation.FieldError;
|
|
|
|
import org.springframework.validation.FieldError;
|
|
|
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
|
|
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.equalTo;
|
|
|
|
|
|
|
|
import static org.hamcrest.Matchers.nullValue;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertNull;
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertThat;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Tests for {@link RelaxedDataBinder}.
|
|
|
|
* Tests for {@link RelaxedDataBinder}.
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -371,6 +370,14 @@ public class RelaxedDataBinderTests {
|
|
|
|
assertEquals("123", target.getNested().get("value.foo"));
|
|
|
|
assertEquals("123", target.getNested().get("value.foo"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
|
|
|
public void testBindNestedProperties() throws Exception {
|
|
|
|
|
|
|
|
TargetWithNestedProperties target = new TargetWithNestedProperties();
|
|
|
|
|
|
|
|
bind(target, "nested.foo: bar\n" + "nested.value.foo: 123");
|
|
|
|
|
|
|
|
assertEquals("bar", target.getNested().get("foo"));
|
|
|
|
|
|
|
|
assertEquals("123", target.getNested().get("value.foo"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@Test
|
|
|
|
public void testBindNestedMapOfEnum() throws Exception {
|
|
|
|
public void testBindNestedMapOfEnum() throws Exception {
|
|
|
|
this.conversionService = new DefaultConversionService();
|
|
|
|
this.conversionService = new DefaultConversionService();
|
|
|
@ -780,6 +787,20 @@ public class RelaxedDataBinderTests {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static class TargetWithNestedProperties {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Properties nested;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Properties getNested() {
|
|
|
|
|
|
|
|
return this.nested;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setNested(Properties nested) {
|
|
|
|
|
|
|
|
this.nested = nested;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class TargetWithNestedMapOfString {
|
|
|
|
public static class TargetWithNestedMapOfString {
|
|
|
|
|
|
|
|
|
|
|
|
private Map<String, String> nested;
|
|
|
|
private Map<String, String> nested;
|
|
|
|