Fix 'Align MimeMappings with Tomcat's defaults'

Update COMMON_MAPPINGS to align with the properties file and change
the test so that it consistently works.

See gh-32101
pull/32162/head
Phillip Webb 2 years ago
parent fe1ffff3d7
commit dd98b88732

@ -261,14 +261,14 @@ public sealed class MimeMappings implements Iterable<MimeMappings.Mapping> {
mappings.add("jpg", "image/jpeg"); mappings.add("jpg", "image/jpeg");
mappings.add("js", "application/javascript"); mappings.add("js", "application/javascript");
mappings.add("json", "application/json"); mappings.add("json", "application/json");
mappings.add("otf", "application/x-font-opentype"); mappings.add("otf", "font/otf");
mappings.add("pdf", "application/pdf"); mappings.add("pdf", "application/pdf");
mappings.add("png", "image/png"); mappings.add("png", "image/png");
mappings.add("ps", "application/postscript"); mappings.add("ps", "application/postscript");
mappings.add("tar", "application/x-tar"); mappings.add("tar", "application/x-tar");
mappings.add("tif", "image/tiff"); mappings.add("tif", "image/tiff");
mappings.add("tiff", "image/tiff"); mappings.add("tiff", "image/tiff");
mappings.add("ttf", "application/x-font-ttf"); mappings.add("ttf", "font/ttf");
mappings.add("txt", "text/plain"); mappings.add("txt", "text/plain");
mappings.add("xht", "application/xhtml+xml"); mappings.add("xht", "application/xhtml+xml");
mappings.add("xhtml", "application/xhtml+xml"); mappings.add("xhtml", "application/xhtml+xml");

@ -174,9 +174,11 @@ class MimeMappingsTests {
@Test @Test
void commonMappingsAreSubsetOfAllMappings() { void commonMappingsAreSubsetOfAllMappings() {
MimeMappings defaultMappings = new DefaultMimeMappings();
MimeMappings commonMappings = (MimeMappings) ReflectionTestUtils.getField(DefaultMimeMappings.class, "COMMON"); MimeMappings commonMappings = (MimeMappings) ReflectionTestUtils.getField(DefaultMimeMappings.class, "COMMON");
defaultMappings.getAll();
for (Mapping commonMapping : commonMappings) { for (Mapping commonMapping : commonMappings) {
assertThat(MimeMappings.DEFAULT.get(commonMapping.getExtension())).isEqualTo(commonMapping.getMimeType()); assertThat(defaultMappings.get(commonMapping.getExtension())).isEqualTo(commonMapping.getMimeType());
} }
} }

Loading…
Cancel
Save