public class XMLSerializerTest {
@Test
public void basicTest() throws IOException, SerializationException {
XMLSerializer xmlSerializer = new XMLSerializer();
Element root = xmlSerializer.readObject(getClass().getResourceAsStream("sample.xml"));
assertEquals(root.getName(), "root");
Element a = XML.getElement(root, "a");
assertEquals(a.getName(), "a");
assertEquals(a.get("id"), "x");
Element b = XML.getElement(root, "a/b");
assertEquals(b.getName(), "b");
assertEquals(b.get("id"), "y");
b = XML.getElement(a, "b");
assertEquals(b.getName(), "b");
assertEquals(b.get("id"), "y");
List<Element> cs = XML.getElements(root, "a/b", "c");
assertEquals(cs.getLength(), 1);
List<Element> fs = XML.getElements(root, "d/e", "f");
assertEquals(fs.getLength(), 4);
Element e = XML.getElement(root, "d/e");
Element f = XML.getElement(e, "f");
assertEquals(f.getName(), "f");
Element g = XML.getElement(e, "g");
assertEquals(g.getName(), "g");
String ft = XML.getText(root, "d/e/f");
assertEquals(ft, "1");
String gt = XML.getText(root, "d/e/g");