Code example for CDATASection

Methods: replaceWholeText

0
        assertEquals(expected, domToString(document));
    } 
 
    public void testReplaceWholeTextMiddle() throws TransformerException { 
        String original = domToString(document);
        Text replacement = descriptionText2.replaceWholeText("Eggos");
        assertSame(descriptionText2, replacement);
        String expected = original.replace(
                "Belgian<![CDATA[ waffles & strawberries (< 5g ]]>of fat)", "<![CDATA[Eggos]]>"); 
        assertEquals("This implementation doesn't remove preceding nodes in replaceWholeText()",
                expected, domToString(document));
    } 
 
    public void testReplaceWholeTextLast() throws TransformerException { 
        String original = domToString(document);
        Text replacement = descriptionText3.replaceWholeText("Eggos");
        assertSame(descriptionText3, replacement);
        String expected = original.replace(
                "Belgian<![CDATA[ waffles & strawberries (< 5g ]]>of fat)", "Eggos"); 
        assertEquals("This implementation doesn't remove preceding nodes in replaceWholeText()",