MediaTypeHeaderProvider implements HeaderDelegate<MediaType> { public MediaType fromString(String mType) { if (mType == null) { throw new IllegalArgumentException("Media type value can not be null"); } int i = mType.indexOf('/'); if (i == -1) { throw new UnsupportedOperationException("Media types without subtype is not supported"); } int paramsStart = mType.indexOf(';', i + 1); int end = paramsStart == -1 ? mType.length() : paramsStart; String type = mType.substring(0, i); String subtype = mType.substring(i + 1, end); return new MediaType(type.trim().toLowerCase(Locale.US), subtype.trim().toLowerCase(Locale.US)); }  MediaType fromString(String mType); String toString(MediaType type);  }
@Test public void testBadType() { try { new MediaTypeHeaderProvider().fromString("texthtml"); fail("Parse exception must've been thrown"); } catch (Exception pe) { } }