@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 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 shouldParseTheCharset() { List<Header> headers = new ArrayList<Header>(); headers.add(new RestData.Header("Content-Type", "application/json; charset=UTF-8")); assertEquals(ContentType.parseCharset(headers), "UTF-8"); }