Example usage for org.springframework.boot.web.server MimeMappings add

List of usage examples for org.springframework.boot.web.server MimeMappings add

Introduction

In this page you can find the example usage for org.springframework.boot.web.server MimeMappings add.

Prototype

public String add(String extension, String mimeType) 

Source Link

Document

Add a new mime mapping.

Usage

From source file:org.springframework.boot.web.servlet.server.AbstractServletWebServerFactoryTests.java

@Test
public void mimeType() throws Exception {
    FileCopyUtils.copy("test", new FileWriter(this.temporaryFolder.newFile("test.xxcss")));
    AbstractServletWebServerFactory factory = getFactory();
    factory.setDocumentRoot(this.temporaryFolder.getRoot());
    MimeMappings mimeMappings = new MimeMappings();
    mimeMappings.add("xxcss", "text/css");
    factory.setMimeMappings(mimeMappings);
    this.webServer = factory.getWebServer();
    this.webServer.start();
    ClientHttpResponse response = getClientResponse(getLocalUrl("/test.xxcss"));
    assertThat(response.getHeaders().getContentType().toString()).isEqualTo("text/css");
    response.close();/*ww w. ja  v  a 2s. co m*/
}