use of org.apache.axiom.om.OMSourcedElement in project webservices-axiom by apache.
the class CloneTestCase method identityCheck.
/**
* Check the identity of each object in the tree
* @param source
* @param target
* @param depth
*/
protected void identityCheck(OMNode source, OMNode target, String depth) {
// System.out.println(depth + source.getClass().getName());
if (source instanceof OMElement) {
if (source instanceof OMSourcedElement) {
assertTrue("Source = " + source.getClass().getName() + "Target = " + target.getClass().getName(), target instanceof OMSourcedElement);
assertEquals(((OMSourcedElement) source).isExpanded(), ((OMSourcedElement) target).isExpanded());
if (((OMSourcedElement) source).isExpanded()) {
Iterator<OMNode> i = ((OMElement) source).getChildren();
Iterator<OMNode> j = ((OMElement) target).getChildren();
while (i.hasNext() && j.hasNext()) {
OMNode sourceChild = i.next();
OMNode targetChild = j.next();
identityCheck(sourceChild, targetChild, depth + " ");
}
assertEquals("Source and Target have different number of children", i.hasNext(), j.hasNext());
}
} else {
assertEquals(source.getClass(), target.getClass());
Iterator<OMNode> i = ((OMElement) source).getChildren();
Iterator<OMNode> j = ((OMElement) target).getChildren();
while (i.hasNext() && j.hasNext()) {
OMNode sourceChild = i.next();
OMNode targetChild = j.next();
identityCheck(sourceChild, targetChild, depth + " ");
}
assertEquals("Source and Target have different number of children", i.hasNext(), j.hasNext());
}
} else {
assertEquals(source.getClass(), target.getClass());
}
}
use of org.apache.axiom.om.OMSourcedElement in project wso2-synapse by wso2.
the class TextFileDataSourceTest method testWithXMLChars.
public void testWithXMLChars() throws Exception {
String testString = "Test string with ampersand (&)";
OMSourcedElement element = createSourcedElement(testString, UTF8);
assertEquals(testString, element.getText());
}
Aggregations