Code example for Text

Methods: replaceWholeText

0
                descriptionText1.getWholeText());
    } 
 
    public void testReplaceWholeTextFirst() throws TransformerException { 
        String original = domToString(document);
        Text replacement = descriptionText1.replaceWholeText("Eggos");
        assertSame(descriptionText1, replacement);
        String expected = original.replace(
                "Belgian<![CDATA[ waffles & strawberries (< 5g ]]>of fat)", "Eggos"); 
        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));
Stop searching for code, let great code find you!  Add Codota to your java IDE