@Test
 public void shouldUseSpecifieDefaultCharsetProperty() {
   List<Header> headers = new ArrayList<Header>();
   headers.add(new RestData.Header("Content-Type", "application/json"));
   Config c = Config.getConfig();
   c.add("restfixture.content.handlers.map", confMap());
   c.add("restfixture.content.default.charset", "MY-CHARSET");
   ContentType.config(c);
   assertEquals(ContentType.parseCharset(headers), "MY-CHARSET");
 }
 @Test
 public void shouldSetupInternalStateFromConfig() {
   StringBuffer configEntry = new StringBuffer();
   configEntry.append("application/x-html=xml<br/>\n");
   Config c = Config.getConfig();
   c.add("restfixture.content.handlers.map", configEntry.toString());
   ContentType.config(c);
   assertEquals(ContentType.XML, ContentType.typeFor("application/x-html"));
   assertEquals(ContentType.XML, ContentType.typeFor("default"));
 }
 @Test
 public void
     shouldUseDefaultSystemCharsetIfCharsetNotParseableAndDefaultNotSpecifiedViaProperty() {
   List<Header> headers = new ArrayList<Header>();
   headers.add(new RestData.Header("Content-Type", "application/json"));
   Config c = Config.getConfig();
   c.add("restfixture.content.handlers.map", confMap());
   c.add("restfixture.content.default.charset", null);
   ContentType.config(c);
   assertEquals(ContentType.parseCharset(headers), Charset.defaultCharset().name());
 }
  @Test
  public void shouldSetupTheContentTypeToAdaptersMapViaConfig() {

    Config c = Config.getConfig();
    c.add("restfixture.content.handlers.map", confMap());
    c.add("restfixture.content.default.charset", "MY-CHARSET");
    ContentType.config(c);

    List<Header> headers = new ArrayList<Header>();
    headers.add(new RestData.Header("Content-Type", "application/json"));
    assertEquals(ContentType.JSON, ContentType.parse(headers));
    headers.set(0, new RestData.Header("Content-Type", "application/xml; charset=iso12344"));
    assertEquals(ContentType.XML, ContentType.parse(headers));
    headers.set(0, new RestData.Header("Content-Type", "application/xhtml"));
    assertEquals(ContentType.XML, ContentType.parse(headers));
    headers.set(0, new RestData.Header("Content-Type", "application/my-app-xml"));
    assertEquals(ContentType.XML, ContentType.parse(headers));
    headers.set(0, new RestData.Header("Content-Type", "text/plain"));
    assertEquals(ContentType.JSON, ContentType.parse(headers));

    // overrides "default"
    headers.set(0, new RestData.Header("Content-Type", "unhandled"));
    assertEquals(ContentType.TEXT, ContentType.parse(headers));
  }