@@ -0,0 +1,2081 @@
+package com.bbn.bue.common.xml;%0A%0Aimport com.google.common.base.Optional;%0A%0Aimport org.junit.Test;%0Aimport org.w3c.dom.Element;%0Aimport org.xml.sax.InputSource;%0Aimport org.xml.sax.SAXException;%0A%0Aimport java.io.IOException;%0Aimport java.io.StringReader;%0A%0Aimport javax.xml.parsers.DocumentBuilder;%0Aimport javax.xml.parsers.DocumentBuilderFactory;%0Aimport javax.xml.parsers.ParserConfigurationException;%0A%0Aimport static com.bbn.bue.common.xml.XMLUtils.nextSibling;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertTrue;%0A%0A/**%0A * Tests XMLUtils.%0A */%0Apublic class XMLUtilsTest %7B%0A%0A  private static Element documentFromString(String source)%0A      throws IOException, SAXException, ParserConfigurationException %7B%0A    DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();%0A    InputSource inputSource = new InputSource(new StringReader(source));%0A    return documentBuilder.parse(inputSource).getDocumentElement();%0A  %7D%0A%0A  /**%0A   * Tests nextSibling.%0A   */%0A  @Test%0A  public void testNextSibling() throws ParserConfigurationException, SAXException, IOException %7B%0A    // Set up%0A    final String childTag = %22child%22;%0A    final String parentWithChildren =%0A        %22%3Cparent%3E%3Cfoo%3Efoo%3C/foo%3E%3Cchild%3Echild1%3C/child%3E%3Cbar%3Ebar%3C/bar%3E%3Cchild%3Echild2%3C/child%3E%3Cbaz%3Ebaz%3C/baz%3E%3C/parent%3E%22;%0A    final Element parent = documentFromString(parentWithChildren);%0A    final Element firstChild = (Element) parent.getFirstChild();%0A%0A    // Check first childTag element%0A    Optional%3CElement%3E result = nextSibling(firstChild, childTag);%0A    assertTrue(result.isPresent());%0A    Element matchingChild = result.get();%0A    assertEquals(%22child1%22, matchingChild.getTextContent());%0A%0A    // Check next childTag element%0A    result = nextSibling(matchingChild, childTag);%0A    assertTrue(result.isPresent());%0A    matchingChild = result.get();%0A    assertEquals(%22child2%22, matchingChild.getTextContent());%0A%0A    // Check that there are no more%0A    result = nextSibling(matchingChild, childTag);%0A    assertFalse(result.isPresent());%0A  %7D%0A%7D%0A

Move XMLUtilsTest to follow XMLUtils