Skip to content

Commit 898d3ec

Browse files
committed
Backport tests for exact match resolution
See gh-34124
1 parent 8ccaabe commit 898d3ec

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

spring-core/src/test/java/org/springframework/util/PropertyPlaceholderHelperTests.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -156,6 +156,23 @@ static Stream<Arguments> defaultValues() {
156156
);
157157
}
158158

159+
@ParameterizedTest(name = "{0} -> {1}")
160+
@MethodSource("exactMatchPlaceholders")
161+
void placeholdersWithExactMatchAreConsidered(String text, String expected) {
162+
Properties properties = new Properties();
163+
properties.setProperty("prefix://my-service", "example-service");
164+
properties.setProperty("px", "prefix");
165+
properties.setProperty("p1", "${prefix://my-service}");
166+
assertThat(this.helper.replacePlaceholders(text, properties)).isEqualTo(expected);
167+
}
168+
169+
static Stream<Arguments> exactMatchPlaceholders() {
170+
return Stream.of(
171+
Arguments.of("${prefix://my-service}", "example-service"),
172+
Arguments.of("${p1}", "example-service")
173+
);
174+
}
175+
159176
}
160177

161178
PlaceholderResolver mockPlaceholderResolver(String... pairs) {

0 commit comments

Comments
 (0)