/** Customize the Servlet engine: Mime types, the document root, the cache. */ @Override public void customize(ConfigurableEmbeddedServletContainer container) { MimeMappings mappings = new MimeMappings(MimeMappings.DEFAULT); // IE issue, see https://github.com/jhipster/generator-jhipster/pull/711 mappings.add("html", "text/html;charset=utf-8"); // CloudFoundry issue, see https://github.com/cloudfoundry/gorouter/issues/64 mappings.add("json", "text/html;charset=utf-8"); container.setMimeMappings(mappings); // When running in an IDE or with ./mvnw spring-boot:run, set location of the static web assets. setLocationForStaticAssets(container); }
@Test public void mimeType() throws Exception { FileCopyUtils.copy("test", new FileWriter(this.temporaryFolder.newFile("test.xxcss"))); AbstractEmbeddedServletContainerFactory factory = getFactory(); factory.setDocumentRoot(this.temporaryFolder.getRoot()); MimeMappings mimeMappings = new MimeMappings(); mimeMappings.add("xxcss", "text/css"); factory.setMimeMappings(mimeMappings); this.container = factory.getEmbeddedServletContainer(); this.container.start(); ClientHttpResponse response = getClientResponse(getLocalUrl("/test.xxcss")); assertThat(response.getHeaders().getContentType().toString(), equalTo("text/css")); response.close(); }