@Test
public void testTrim() {

    assertEquals(
            "text/plain",
            new MediaType(" text ", " plain ").toString());
    assertEquals(
            "text/plain",
            new MediaType("\ttext", "plain\t").toString());
    Map<String, String> parameters = new HashMap<String, String>();
    assertEquals(
            "text/plain",
            new MediaType("text\r\n", " \tplain", parameters).toString());
    parameters.put(" charset", "UTF-8");
    assertEquals(
            "text/plain; charset=UTF-8",
            new MediaType("\n\ntext", "plain \r", parameters).toString());
    parameters.put("\r\n\tx-eol-style  \t", "crlf");
    assertEquals(
            "text/plain; charset=UTF-8; x-eol-style=crlf",
        new MediaType("    text", "\tplain ", parameters).toString());
}