use of org.w3c.dom.Text in project webservices-axiom by apache.
the class TestSetTextContent method runTest.
protected void runTest() throws Throwable {
Document doc = dbf.newDocumentBuilder().parse(new InputSource(new StringReader("<a>1<!--c--><b>2</b>3</a>")));
Element element = doc.getDocumentElement();
Node oldFirstChild = element.getFirstChild();
element.setTextContent("test");
Node firstChild = element.getFirstChild();
assertTrue(firstChild instanceof Text);
assertEquals("test", firstChild.getNodeValue());
assertNull(firstChild.getNextSibling());
assertNull(oldFirstChild.getParentNode());
assertSame(doc, oldFirstChild.getOwnerDocument());
}
use of org.w3c.dom.Text in project webservices-axiom by apache.
the class TestAppendData method runTest.
protected void runTest() throws Exception {
Document document = dbf.newDocumentBuilder().newDocument();
String localName = "TestLocalName";
String namespace = "http://ws.apache.org/axis2/ns";
String prefix = "axis2";
String tempText = "The quick brown fox jumps over the lazy dog";
String textToAppend = " followed by another fox";
Element elem = document.createElementNS(namespace, prefix + ":" + localName);
Text textNode = document.createTextNode(tempText);
elem.appendChild(textNode);
textNode.appendData(textToAppend);
assertEquals("Text value mismatch", tempText + textToAppend, textNode.getData());
}
use of org.w3c.dom.Text in project webservices-axiom by apache.
the class TestGetWholeText method runTest.
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
Element element = document.createElementNS(null, "test");
element.appendChild(document.createTextNode("a"));
element.appendChild(document.createElementNS(null, "x"));
element.appendChild(document.createTextNode("b"));
Text c = document.createTextNode("c");
element.appendChild(c);
element.appendChild(document.createTextNode("d"));
element.appendChild(document.createProcessingInstruction("test", "test"));
element.appendChild(document.createTextNode("e"));
assertEquals("bcd", c.getWholeText());
}
use of org.w3c.dom.Text in project webservices-axiom by apache.
the class TestGetWholeTextWithComment method runTest.
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
Element element = document.createElementNS(null, "test");
Text a = document.createTextNode("a");
element.appendChild(a);
element.appendChild(document.createComment("comment"));
element.appendChild(document.createTextNode("b"));
assertEquals("a", a.getWholeText());
}
use of org.w3c.dom.Text in project webservices-axiom by apache.
the class TestGetWholeTextWithCDATASection method runTest.
protected void runTest() throws Throwable {
Document document = dbf.newDocumentBuilder().newDocument();
Element element = document.createElementNS(null, "test");
Text a = document.createTextNode("a");
element.appendChild(a);
element.appendChild(document.createCDATASection("b"));
element.appendChild(document.createTextNode("c"));
assertEquals("abc", a.getWholeText());
}
Aggregations