### Question:
ImmutableMediaType implements MediaType { @Override public String toString() { return MoreObjects. toStringHelper(getClass()). omitNullValues(). add("type",this.type). add("subtype",this.subtype). add("suffix",this.suffix). add("parameters",this.parameters). toString(); } ImmutableMediaType(final MediaRangeSyntax syntax, final String type, final String subtype, String suffix, final Map<String, String> parameters); @Override String type(); @Override String subType(); @Override Charset charset(); @Override String suffix(); @Override Map<String,String> parameters(); @Override boolean isWildcard(); @Override String toHeader(); @Override int hashCode(); @Override boolean equals(final Object other); @Override String toString();  }### Answer:
@Test public void cannotParseMediaTypesWithDanglingQuotedPair() throws Exception { try { createParam("myparam=\"a"+Character.toString('\\')+offending()+"a\""); fail("Should fail for dangling quoted pair"); } catch (final InvalidMediaTypeException e) { assertThat(Throwables.getRootCause(e).getMessage(),containsString("Invalid quoted-pair character '"+offending()+"'")); } }
@Test public void cannotParseMediaTypesWithDanglingInitialQuotedPair() throws Exception { try { createParam("myparam=\""+Character.toString('\\')+offending()+"a\""); fail("Should fail for dangling initial quoted pair"); } catch (final InvalidMediaTypeException e) { assertThat(Throwables.getRootCause(e).getMessage(),containsString("Invalid quoted-pair character '"+offending()+"'")); } }
@Test public void mediaTypesWithCompatibleCharsetsAreEqual() { final ImmutableMediaType one=defaultMediaType().build(); final ImmutableMediaType other=defaultMediaType().withCompatibleCharset().build(); assertThat(one.toString(),not(equalTo(other.toString()))); assertThat(one,equalTo(other)); }