From 9d56b419cdeaaf7c7cb43415ec314313447ea3af Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 8 May 2023 15:08:02 +0200 Subject: [PATCH] Adapt to change in Spring Framework snapshots Binding to an HashMap now consistently return a LinkedHashMap. --- .../boot/context/properties/bind/MapBinderTests.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java index 7b86c969206..c15ae41b818 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/bind/MapBinderTests.java @@ -24,6 +24,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Properties; +import java.util.SortedMap; import java.util.stream.Collectors; import org.junit.jupiter.api.Test; @@ -244,7 +245,7 @@ class MapBinderTests { existing.put("baz", 1001); Bindable> target = STRING_INTEGER_MAP.withExistingValue(existing); Map result = this.binder.bind("foo", target).get(); - assertThat(result).isExactlyInstanceOf(HashMap.class); + assertThat(result).isInstanceOf(HashMap.class); assertThat(result).hasSize(2); assertThat(result).containsEntry("bar", 1); assertThat(result).containsEntry("baz", 1001); @@ -253,10 +254,10 @@ class MapBinderTests { @Test void bindToMapShouldRespectMapType() { this.sources.add(new MockConfigurationPropertySource("foo.bar", "1")); - ResolvableType type = ResolvableType.forClassWithGenerics(HashMap.class, String.class, Integer.class); + ResolvableType type = ResolvableType.forClassWithGenerics(SortedMap.class, String.class, Integer.class); Object defaultMap = this.binder.bind("foo", STRING_INTEGER_MAP).get(); Object customMap = this.binder.bind("foo", Bindable.of(type)).get(); - assertThat(customMap).isExactlyInstanceOf(HashMap.class).isNotInstanceOf(defaultMap.getClass()); + assertThat(customMap).isInstanceOf(SortedMap.class).isNotInstanceOf(defaultMap.getClass()); } @Test