@ -41,7 +41,6 @@ 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.boot.bind.RelaxedDataBinder ;
import org.springframework.context.support.StaticMessageSource ;
import org.springframework.context.support.StaticMessageSource ;
import org.springframework.core.convert.ConversionService ;
import org.springframework.core.convert.ConversionService ;
import org.springframework.core.convert.support.DefaultConversionService ;
import org.springframework.core.convert.support.DefaultConversionService ;
@ -75,6 +74,34 @@ public class RelaxedDataBinderTests {
assertEquals ( "bar" , target . getFoo ( ) ) ;
assertEquals ( "bar" , target . getFoo ( ) ) ;
}
}
@Test
public void testBindStringWithPrefix ( ) throws Exception {
VanillaTarget target = new VanillaTarget ( ) ;
bind ( target , "test.foo: bar" , "test" ) ;
assertEquals ( "bar" , target . getFoo ( ) ) ;
}
@Test
public void testBindFromEnvironmentStyleWithPrefix ( ) throws Exception {
VanillaTarget target = new VanillaTarget ( ) ;
bind ( target , "TEST_FOO: bar" , "test" ) ;
assertEquals ( "bar" , target . getFoo ( ) ) ;
}
@Test
public void testBindFromEnvironmentStyleWithNestedPrefix ( ) throws Exception {
VanillaTarget target = new VanillaTarget ( ) ;
bind ( target , "TEST_IT_FOO: bar" , "test.it" ) ;
assertEquals ( "bar" , target . getFoo ( ) ) ;
}
@Test
public void testBindCapitals ( ) throws Exception {
VanillaTarget target = new VanillaTarget ( ) ;
bind ( target , "FOO: bar" ) ;
assertEquals ( "bar" , target . getFoo ( ) ) ;
}
@Test
@Test
public void testBindUnderscoreInActualPropertyName ( ) throws Exception {
public void testBindUnderscoreInActualPropertyName ( ) throws Exception {
VanillaTarget target = new VanillaTarget ( ) ;
VanillaTarget target = new VanillaTarget ( ) ;
@ -215,8 +242,6 @@ public class RelaxedDataBinderTests {
}
}
@Test
@Test
// @Ignore("Should be possible but currently not supported")
// FIXME: bind to map containing beans
public void testBindNestedMapOfBean ( ) throws Exception {
public void testBindNestedMapOfBean ( ) throws Exception {
TargetWithNestedMapOfBean target = new TargetWithNestedMapOfBean ( ) ;
TargetWithNestedMapOfBean target = new TargetWithNestedMapOfBean ( ) ;
bind ( target , "nested.foo.foo: bar\n" + "nested.bar.foo: bucket" ) ;
bind ( target , "nested.foo.foo: bar\n" + "nested.bar.foo: bucket" ) ;
@ -225,8 +250,6 @@ public class RelaxedDataBinderTests {
}
}
@Test
@Test
// @Ignore("Should be possible but currently not supported")
// FIXME: bind to map containing beans
public void testBindNestedMapOfListOfBean ( ) throws Exception {
public void testBindNestedMapOfListOfBean ( ) throws Exception {
TargetWithNestedMapOfListOfBean target = new TargetWithNestedMapOfListOfBean ( ) ;
TargetWithNestedMapOfListOfBean target = new TargetWithNestedMapOfListOfBean ( ) ;
bind ( target , "nested.foo[0].foo: bar\n" + "nested.bar[0].foo: bucket\n"
bind ( target , "nested.foo[0].foo: bar\n" + "nested.bar[0].foo: bucket\n"