@Test
public void testWithCharset() throws Exception {

    ContentType contentType = ContentType.create("text/plain", "US-ASCII");
    Assert.assertEquals("text/plain", contentType.getMimeType());
    Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
    Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
    contentType = contentType.withCharset(Charset.forName("UTF-8"));
    Assert.assertEquals("text/plain", contentType.getMimeType());
    Assert.assertEquals("UTF-8", contentType.getCharset().name());
    Assert.assertEquals("text/plain; charset=UTF-8", contentType.toString());
}