private static void checkXmlWriter(final String text, final String encoding, final String defaultEncoding) throws IOException { final String xml = createXmlContent(text, encoding); String effectiveEncoding = encoding; if (effectiveEncoding == null) { effectiveEncoding = defaultEncoding == null ? "UTF-8" : defaultEncoding; } checkXmlContent(xml, effectiveEncoding, defaultEncoding); }
private static void checkXmlWriter(final String text, final String encoding) throws IOException { checkXmlWriter(text, encoding, null); }
@Test public void testNoXmlHeader() throws IOException { final String xml = "<text>text with no XML header</text>"; checkXmlContent(xml, "UTF-8", null); }
@Test public void testDefaultEncoding() throws IOException { checkXmlWriter(TEXT_UNICODE, null, null); checkXmlWriter(TEXT_UNICODE, null, "UTF-8"); checkXmlWriter(TEXT_UNICODE, null, "UTF-16"); checkXmlWriter(TEXT_UNICODE, null, "UTF-16BE"); checkXmlWriter(TEXT_UNICODE, null, "ISO-8859-1"); }
@Test public void testUTF16LEEncoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-16LE"); }
@Test public void testEBCDICEncoding() throws IOException { checkXmlWriter("simple text in EBCDIC", "CP1047"); } }
@Test public void testUTF16Encoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-16"); }
@Test public void testLatin1Encoding() throws IOException { checkXmlWriter(TEXT_LATIN1, "ISO-8859-1"); }
@Test public void testUTF8Encoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-8"); }
@Test public void testUTF16BEEncoding() throws IOException { checkXmlWriter(TEXT_UNICODE, "UTF-16BE"); }
@Test public void testLatin7Encoding() throws IOException { checkXmlWriter(TEXT_LATIN7, "ISO-8859-7"); }
@Test public void testLatin15Encoding() throws IOException { checkXmlWriter(TEXT_LATIN15, "ISO-8859-15"); }
@Test public void testEUC_JPEncoding() throws IOException { checkXmlWriter(TEXT_EUC_JP, "EUC-JP"); }