ContentType { public void setCharset(String charset) { if(this.charset == null) { throw new UnsupportedCharsetException("provided mediatype does not support setting charset"); } if(StringUtils.isNotEmpty(charset)) { this.charset = Charset.forName(charset); } } ContentType(MediaTypes mediaType); void setCharset(String charset); Charset getCharset(); String getContentType(); static final String CHARSET_PARAMETER; }
@Test(expected=UnsupportedCharsetException.class) public void faultyCharset() { ContentType contentType = new ContentType(MediaTypes.TEXT); contentType.setCharset("ISO-1234"); }