2 * Copyright (c) 2022 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.connect.netconf;
10 import static org.junit.Assert.assertTrue;
12 import java.io.IOException;
13 import javax.xml.transform.dom.DOMSource;
14 import org.custommonkey.xmlunit.XMLUnit;
15 import org.junit.BeforeClass;
16 import org.junit.Test;
17 import org.opendaylight.netconf.api.xml.XmlUtil;
18 import org.xml.sax.SAXException;
20 public class NC881Test {
22 public static void classSetUp() {
23 XMLUnit.setIgnoreWhitespace(true);
27 public void testFilterDomNamespaces() throws IOException, SAXException {
28 final var source = XmlUtil.readXmlToDocument(
29 getClass().getResourceAsStream("/nc881/netconf-state.xml"));
30 final var expected = XmlUtil.readXmlToDocument(
31 getClass().getResourceAsStream("/nc881/netconf-state-filtered.xml"));
33 final var filteredDom = NetconfStateSchemas.ietfMonitoringCopy(new DOMSource(source.getDocumentElement()));
34 final var filtered = XmlUtil.newDocument();
35 filtered.appendChild(filtered.importNode(filteredDom.getNode(), true));
37 final var diff = XMLUnit.compareXML(filtered, expected);
38 assertTrue(diff.toString(), diff.similar());