From fac04c12287192758fb23e628a1bde1b3212ae38 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 3 Aug 2015 15:03:19 +0200 Subject: [PATCH] Add test #3386 was actually fixed as part of #2387. Add the test that used to reproduce the issue. --- .../boot/bind/RelaxedDataBinderTests.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java b/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java index 1c29151aea..00bc24bad7 100644 --- a/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/bind/RelaxedDataBinderTests.java @@ -56,6 +56,7 @@ 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; @@ -64,6 +65,7 @@ import static org.junit.Assert.assertThat; * * @author Dave Syer * @author Phillip Webb + * @author Stephane Nicoll */ public class RelaxedDataBinderTests { @@ -346,6 +348,22 @@ public class RelaxedDataBinderTests { assertEquals("123", target.getNested().get("foo.value")); } + @SuppressWarnings("unchecked") + @Test + public void testBindDoubleNestedMapWithDotInKeys() throws Exception { + TargetWithNestedMap target = new TargetWithNestedMap(); + bind(target, "nested.foo: bar.key\n" + "nested[bar.key].spam: bucket\n" + + "nested[bar.key].value: 123\nnested[bar.key].foo: crap"); + assertEquals(2, target.getNested().size()); + Map nestedMap = (Map) target.getNested().get("bar.key"); + assertNotNull("nested map should be registered with 'bar.key'", nestedMap); + assertEquals(3, nestedMap.size()); + assertEquals("123", + nestedMap.get("value")); + assertEquals("bar.key", target.getNested().get("foo")); + assertFalse(target.getNested().containsValue(target.getNested())); + } + @SuppressWarnings("unchecked") @Test public void testBindDoubleNestedMap() throws Exception {