@Test
  public void resolveMediaTypesFromJaf() {
    this.servletRequest.setRequestURI("test.xls");
    PathExtensionContentNegotiationStrategy strategy =
        new PathExtensionContentNegotiationStrategy();

    List<MediaType> mediaTypes = strategy.resolveMediaTypes(this.webRequest);

    assertEquals(Arrays.asList(new MediaType("application", "vnd.ms-excel")), mediaTypes);
  }
  @Test
  public void getMediaTypeFromFilenameNoJaf() {
    this.servletRequest.setRequestURI("test.xls");
    PathExtensionContentNegotiationStrategy strategy =
        new PathExtensionContentNegotiationStrategy();
    strategy.setUseJaf(false);

    List<MediaType> mediaTypes = strategy.resolveMediaTypes(this.webRequest);

    assertEquals(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM), mediaTypes);
  }
  @Test
  public void getMediaTypeFilenameWithEncodedURI() {
    this.servletRequest.setRequestURI("/quo%20vadis%3f.html");
    PathExtensionContentNegotiationStrategy strategy =
        new PathExtensionContentNegotiationStrategy();

    List<MediaType> result = strategy.resolveMediaTypes(webRequest);

    assertEquals(
        "Invalid content type", Collections.singletonList(new MediaType("text", "html")), result);
  }
  @Test
  public void getMediaTypeFilenameWithContextPath() {
    this.servletRequest.setContextPath("/project-1.0.0.M3");
    this.servletRequest.setRequestURI("/project-1.0.0.M3/");
    PathExtensionContentNegotiationStrategy strategy =
        new PathExtensionContentNegotiationStrategy();

    assertTrue("Context path should be excluded", strategy.resolveMediaTypes(webRequest).isEmpty());

    this.servletRequest.setRequestURI("/project-1.0.0.M3");

    assertTrue("Context path should be excluded", strategy.resolveMediaTypes(webRequest).isEmpty());
  }
  @Test
  public void resolveMediaTypesFromMapping() {
    this.servletRequest.setRequestURI("test.html");
    PathExtensionContentNegotiationStrategy strategy =
        new PathExtensionContentNegotiationStrategy();

    List<MediaType> mediaTypes = strategy.resolveMediaTypes(this.webRequest);

    assertEquals(Arrays.asList(new MediaType("text", "html")), mediaTypes);

    strategy =
        new PathExtensionContentNegotiationStrategy(
            Collections.singletonMap("HTML", MediaType.APPLICATION_XHTML_XML));
    mediaTypes = strategy.resolveMediaTypes(this.webRequest);

    assertEquals(Arrays.asList(new MediaType("application", "xhtml+xml")), mediaTypes);
  }