Skip to content

Commit 4c52de3

Browse files
committed
Merge pull request spring-projects#30692 from terminux
* pr/30692: Polish "Validate overrides against CharsetMapperDefault.properties" Validate overrides against CharsetMapperDefault.properties Closes spring-projectsgh-30692
2 parents 2c30d66 + 1fa4701 commit 4c52de3

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import java.util.HashMap;
2828
import java.util.Locale;
2929
import java.util.Map;
30+
import java.util.Properties;
3031
import java.util.concurrent.Future;
3132
import java.util.concurrent.atomic.AtomicReference;
3233

@@ -80,6 +81,8 @@
8081
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
8182
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
8283
import org.springframework.core.io.ByteArrayResource;
84+
import org.springframework.core.io.ClassPathResource;
85+
import org.springframework.core.io.support.PropertiesLoaderUtils;
8386
import org.springframework.http.HttpEntity;
8487
import org.springframework.http.HttpHeaders;
8588
import org.springframework.http.HttpStatus;
@@ -405,13 +408,15 @@ protected TomcatWebServer getTomcatWebServer(Tomcat tomcat) {
405408
}
406409

407410
@Test
408-
void defaultLocaleCharsetMappingsAreOverridden() {
411+
void defaultLocaleCharsetMappingsAreOverridden() throws IOException {
409412
TomcatServletWebServerFactory factory = getFactory();
410413
this.webServer = factory.getWebServer();
411414
// override defaults, see org.apache.catalina.util.CharsetMapperDefault.properties
412-
assertThat(getCharset(Locale.ENGLISH)).isEqualTo(StandardCharsets.UTF_8);
413-
assertThat(getCharset(Locale.FRENCH)).isEqualTo(StandardCharsets.UTF_8);
414-
assertThat(getCharset(Locale.JAPANESE)).isEqualTo(StandardCharsets.UTF_8);
415+
Properties charsetMapperDefault = PropertiesLoaderUtils
416+
.loadProperties(new ClassPathResource("CharsetMapperDefault.properties", CharsetMapper.class));
417+
for (String language : charsetMapperDefault.stringPropertyNames()) {
418+
assertThat(getCharset(new Locale(language))).isEqualTo(StandardCharsets.UTF_8);
419+
}
415420
}
416421

417422
@Test

0 commit comments

Comments
 (0)