Example #1
0
  @Test
  public void parse_without_parameters() throws Exception {
    ContentType contentType = new ContentType("text/html");

    assertEquals(contentType.getBaseType(), "text");

    assertEquals(contentType.getSubType(), "html");

    assertEquals(contentType.getMimeType(), "text/html");

    assertTrue(contentType.getParameterNames().isEmpty());
  }
Example #2
0
  @Test
  public void parse_with_parameters() throws Exception {
    ContentType contentType = new ContentType("text/html;charset=utf-8");

    assertEquals(contentType.getBaseType(), "text");

    assertEquals(contentType.getSubType(), "html");

    assertEquals(contentType.getMimeType(), "text/html");

    List<String> parameterNames = contentType.getParameterNames();
    assertEquals(parameterNames.size(), 1);

    assertEquals(parameterNames.get(0), "charset");

    assertEquals(contentType.getCharset(), "utf-8");

    String nonexistant = contentType.getParameter("nonexistant");
    assertTrue(nonexistant == null);
  }