use of org.apache.pivot.xml.XMLSerializerListener in project pivot by apache.
the class XMLSerializerTest method equalsTest.
@Test
public void equalsTest() throws IOException, SerializationException {
XMLSerializer xmlSerializer = new XMLSerializer();
XMLSerializerListener xmlSerializerListener = new XMLSerializerListener() {
@Override
public void beginElement(XMLSerializer xmlSerializerArgument, Element element) {
System.out.println("Begin element: " + element);
}
@Override
public void endElement(XMLSerializer xmlSerializerArgument) {
System.out.println("End element");
}
@Override
public void readTextNode(XMLSerializer xmlSerializerArgument, TextNode textNode) {
System.out.println("Read text node: " + textNode);
}
};
xmlSerializer.getXMLSerializerListeners().add(xmlSerializerListener);
Element root1 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
assertNotNull(root1);
xmlSerializer.getXMLSerializerListeners().remove(xmlSerializerListener);
Element root2 = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
assertNotNull(root2);
}
Aggregations