Remove test dependency on xerces 96/77296/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 26 Oct 2018 09:25:05 +0000 (11:25 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 26 Oct 2018 09:27:59 +0000 (11:27 +0200)
The test is mucking into a concrete implementation, use normal
API method to acquire the value for assertion.

Change-Id: I32699f6e37f922ca43d1791d0fa2604dd0aa9412
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit cc20caf752d137f0cfef2cdb3daa9083697b6f42)

netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java

index e45af697eff1f3319e6cf8a53f0b4b2400e54327..ee3605f86183d17efb17c634678a177ee0f0fb87 100644 (file)
@@ -42,7 +42,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import javax.xml.transform.dom.DOMSource;
-import org.apache.xerces.dom.TextImpl;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.ElementNameAndAttributeQualifier;
 import org.custommonkey.xmlunit.XMLUnit;
@@ -433,8 +432,8 @@ public class NetconfMessageTransformerTest {
         Node childName = childServer.getFirstChild();
         checkNode(childName, "name", "name", qname.getNamespace().toString());
 
-        TextImpl childTest = (TextImpl) childName.getFirstChild();
-        assertEquals(childTest.getData(), "test");
+        Node childTest = childName.getFirstChild();
+        assertEquals(childTest.getNodeValue(), "test");
 
         checkAction(actionResetQName, childName.getNextSibling(), "reset-at", "reset-at", "now");
     }
@@ -507,18 +506,18 @@ public class NetconfMessageTransformerTest {
         assertEquals("now", leaf.getValue());
     }
 
-    private void checkAction(QName actionQname, Node action , String inputLocalName, String inputNodeName,
-            String inputValue) {
+    private static void checkAction(final QName actionQname, final Node action , final String inputLocalName,
+            final String inputNodeName, final String inputValue) {
         checkNode(action, null, actionQname.getLocalName(), null);
 
         Node childResetAt = action.getFirstChild();
         checkNode(childResetAt, inputLocalName, inputNodeName, actionQname.getNamespace().toString());
 
-        TextImpl firstChild = (TextImpl) childResetAt.getFirstChild();
-        assertEquals(firstChild.getData(), inputValue);
+        Node firstChild = childResetAt.getFirstChild();
+        assertEquals(firstChild.getNodeValue(), inputValue);
     }
 
-    private Node checkBasePartOfActionRequest(NetconfMessage actionRequest) {
+    private static Node checkBasePartOfActionRequest(final NetconfMessage actionRequest) {
         Node baseRpc = actionRequest.getDocument().getFirstChild();
         checkNode(baseRpc, "rpc", "rpc", NetconfMessageTransformUtil.NETCONF_QNAME.getNamespace().toString());
         assertTrue(baseRpc.getLocalName().equals("rpc"));
@@ -533,7 +532,7 @@ public class NetconfMessageTransformerTest {
         return childAction;
     }
 
-    private DOMDataTreeIdentifier prepareDataTreeId(Set<PathArgument> nodeIdentifiers) {
+    private static DOMDataTreeIdentifier prepareDataTreeId(final Set<PathArgument> nodeIdentifiers) {
         YangInstanceIdentifier yangInstanceIdentifier =
                 YangInstanceIdentifier.builder().append(nodeIdentifiers).build();
         DOMDataTreeIdentifier domDataTreeIdentifier =
@@ -542,7 +541,7 @@ public class NetconfMessageTransformerTest {
         return domDataTreeIdentifier;
     }
 
-    private ContainerNode initInputAction(QName qname, String value) {
+    private static ContainerNode initInputAction(final QName qname, final String value) {
         ImmutableLeafNodeBuilder<String> immutableLeafNodeBuilder = new ImmutableLeafNodeBuilder<>();
         DataContainerChild<NodeIdentifier, String> build = immutableLeafNodeBuilder.withNodeIdentifier(
                 NodeIdentifier.create(qname)).withValue(value).build();
@@ -551,19 +550,19 @@ public class NetconfMessageTransformerTest {
         return data;
     }
 
-    private void checkNode(Node childServer, String expectedLocalName, String expectedNodeName,
-            String expectedNamespace) {
+    private static void checkNode(final Node childServer, final String expectedLocalName, final String expectedNodeName,
+            final String expectedNamespace) {
         assertNotNull(childServer);
         assertEquals(childServer.getLocalName(), expectedLocalName);
         assertEquals(childServer.getNodeName(), expectedNodeName);
         assertEquals(childServer.getNamespaceURI(), expectedNamespace);
     }
 
-    private SchemaContext getActionSchema() {
+    private static SchemaContext getActionSchema() {
         return YangParserTestUtils.parseYangResource("/schemas/example-server-farm.yang");
     }
 
-    private NetconfMessageTransformer getActionMessageTransformer() {
+    private static NetconfMessageTransformer getActionMessageTransformer() {
         return new NetconfMessageTransformer(getActionSchema(), true);
     }
 }