From c59ca087b4066b99eabc76348fdfc1c2c500e68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Nicoll?= Date: Mon, 23 Dec 2024 11:29:32 +0100 Subject: [PATCH] Backport tests for exact match resolution See gh-34124 (cherry picked from commit 898d3ec86aaaaa76f69f1e65adf9b52f6a26e7ff) --- .../util/PropertyPlaceholderHelperTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java b/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java index 3b0e1650177..842ceb7a7f1 100644 --- a/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java +++ b/spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java @@ -153,6 +153,23 @@ class PropertyPlaceholderHelperTests { ); } + @ParameterizedTest(name = "{0} -> {1}") + @MethodSource("exactMatchPlaceholders") + void placeholdersWithExactMatchAreConsidered(String text, String expected) { + Properties properties = new Properties(); + properties.setProperty("prefix://my-service", "example-service"); + properties.setProperty("px", "prefix"); + properties.setProperty("p1", "${prefix://my-service}"); + assertThat(this.helper.replacePlaceholders(text, properties)).isEqualTo(expected); + } + + static Stream exactMatchPlaceholders() { + return Stream.of( + Arguments.of("${prefix://my-service}", "example-service"), + Arguments.of("${p1}", "example-service") + ); + } + } PlaceholderResolver mockPlaceholderResolver(String... pairs) {