From 1978c16ab61a62f09241ec95f0cfb9c087f1b0f5 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Fri, 26 Oct 2018 11:25:05 +0200 Subject: [PATCH] Remove test dependency on xerces 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 (cherry picked from commit cc20caf752d137f0cfef2cdb3daa9083697b6f42) --- .../NetconfMessageTransformerTest.java | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java index e45af697ef..ee3605f861 100644 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java +++ b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/NetconfMessageTransformerTest.java @@ -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 nodeIdentifiers) { + private static DOMDataTreeIdentifier prepareDataTreeId(final Set 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 immutableLeafNodeBuilder = new ImmutableLeafNodeBuilder<>(); DataContainerChild 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); } } -- 2.36.6