Skip to content

Commit f66eef1

Browse files
committed
Fix SortedPropertiesTests on JDK 9+
1 parent eacc531 commit f66eef1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-core/src/test/java/org/springframework/core/SortedPropertiesTests.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,11 @@ public void storingAsXmlSortsPropertiesAndOmitsComments() throws IOException {
132132

133133
String[] lines = lines(baos);
134134

135-
assertThat(lines).containsExactly( //
136-
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>", //
135+
assertThat(lines).isNotEmpty();
136+
// Leniently match first line due to differences between JDK 8 and JDK 9+.
137+
String regex = "<\\?xml .*\\?>";
138+
assertThat(lines[0]).matches(regex);
139+
assertThat(lines).filteredOn(line -> !line.matches(regex)).containsExactly( //
137140
"<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">", //
138141
"<properties>", //
139142
"<entry key=\"color\">blue</entry>", //

0 commit comments

Comments
 (0)