Merge pull request #30692 from terminux

* pr/30692:
  Polish "Validate overrides against CharsetMapperDefault.properties"
  Validate overrides against CharsetMapperDefault.properties

Closes gh-30692
pull/30878/head
Stephane Nicoll 3 years ago
commit 4c52de3ef7

@ -27,6 +27,7 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReference;
@ -80,6 +81,8 @@ import org.springframework.boot.web.server.WebServerException;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
@ -405,13 +408,15 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
}
@Test
void defaultLocaleCharsetMappingsAreOverridden() {
void defaultLocaleCharsetMappingsAreOverridden() throws IOException {
TomcatServletWebServerFactory factory = getFactory();
this.webServer = factory.getWebServer();
// override defaults, see org.apache.catalina.util.CharsetMapperDefault.properties
assertThat(getCharset(Locale.ENGLISH)).isEqualTo(StandardCharsets.UTF_8);
assertThat(getCharset(Locale.FRENCH)).isEqualTo(StandardCharsets.UTF_8);
assertThat(getCharset(Locale.JAPANESE)).isEqualTo(StandardCharsets.UTF_8);
Properties charsetMapperDefault = PropertiesLoaderUtils
.loadProperties(new ClassPathResource("CharsetMapperDefault.properties", CharsetMapper.class));
for (String language : charsetMapperDefault.stringPropertyNames()) {
assertThat(getCharset(new Locale(language))).isEqualTo(StandardCharsets.UTF_8);
}
}
@Test

Loading…
Cancel
Save