Add test for CDATA Sections
This commit is contained in:
parent
19b08a71a2
commit
6c8d1d2bf2
@ -31,6 +31,18 @@ public class InvalidCharactersUnitTest {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void givenXml_whenUsingCdataForReservedCharacters_thenSuccess() {
|
||||||
|
String validXmlString = "<?xml version=\"1.1\" encoding=\"UTF-8\"?><root><name><![CDATA[John & Doe]]></name></root>";
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> {
|
||||||
|
Document document = parseXmlString(validXmlString);
|
||||||
|
|
||||||
|
assertNotNull(document);
|
||||||
|
assertEquals("John & Doe", document.getElementsByTagName("name").item(0).getTextContent());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenXml_whenUnicodeCharacters_thenThrowException() {
|
void givenXml_whenUnicodeCharacters_thenThrowException() {
|
||||||
String invalidXmlString = "<?xml version=\"1.1\" encoding=\"UTF-8\"?><root><name>John \u001E Doe</name></root>";
|
String invalidXmlString = "<?xml version=\"1.1\" encoding=\"UTF-8\"?><root><name>John \u001E Doe</name></root>";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user