@Test
  public void testAddNewNodeReplaceNamed() throws Exception {
    final String xPath = "/cache:cache/cache:region[@name='r1']";
    NodeList nodes = XmlUtils.query(config, xPath, xPathContext);
    assertEquals(1, nodes.getLength());
    Element element = (Element) nodes.item(0);
    assertEquals(1, getElementNodes(element.getChildNodes()).size());
    assertEquals(CacheXml.GEODE_NAMESPACE, element.getNamespaceURI());

    final Document changes = XmlUtils.createDocumentFromReader(new InputStreamReader(getClass()
        .getResourceAsStream("XmlUtilsAddNewNodeJUnitTest.testAddNewNodeReplaceNamed.xml")));
    nodes = XmlUtils.query(changes, xPath, xPathContext);
    assertEquals(1, nodes.getLength());
    element = (Element) nodes.item(0);
    assertEquals(0, element.getChildNodes().getLength());
    assertEquals(CacheXml.GEODE_NAMESPACE, element.getNamespaceURI());

    final XmlEntity xmlEntity = XmlEntity.builder().withType("region").withAttribute("name", "r1")
        .withConfig(changes).build();
    XmlUtils.addNewNode(config, xmlEntity);

    nodes = XmlUtils.query(config, xPath, xPathContext);
    assertEquals(1, nodes.getLength());
    element = (Element) nodes.item(0);
    assertEquals(0, element.getChildNodes().getLength());
    assertEquals(CacheXml.GEODE_NAMESPACE, element.getNamespaceURI());
  }
Tests {@link XmlUtils#addNewNode(Document, XmlEntity)} with {@link CacheXml} element with a
<code>name</code> attribute, <code>region</code>. It should replace existing
<code>region</code> element with same <code>name</code>.

@since GemFire 8.1
geode-core/src/integrationTest/java/org/apache/geode/management/internal/configuration/utils/XmlUtilsAddNewNodeJUnitTest.java