Add test for CDATA Sections

This commit is contained in:
anujgaud 2024-03-09 20:36:27 +05:30 committed by GitHub
parent 19b08a71a2
commit 6c8d1d2bf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 0 deletions

View File

@ -30,6 +30,18 @@ public class InvalidCharactersUnitTest {
assertEquals("John & Doe", document.getElementsByTagName("name").item(0).getTextContent());
});
}
@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
void givenXml_whenUnicodeCharacters_thenThrowException() {