X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=netconf%2Fsal-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fschema%2Fmapping%2FSchemalessMessageTransformerTest.java;fp=netconf%2Fsal-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Fschema%2Fmapping%2FSchemalessMessageTransformerTest.java;h=0000000000000000000000000000000000000000;hb=22cb88b09661d3a13bfb8ed6d31cc4ad4c6c5a4a;hp=06e307394cd7258c7cd5df6a0a4c4495248ffa60;hpb=0009fbaa0f1c512295711e7b65f0adad9e43554e;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java b/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java deleted file mode 100644 index 06e307394c..0000000000 --- a/netconf/sal-netconf-connector/src/test/java/org/opendaylight/netconf/sal/connect/netconf/schema/mapping/SchemalessMessageTransformerTest.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.sal.connect.netconf.schema.mapping; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import javax.xml.transform.dom.DOMSource; -import org.custommonkey.xmlunit.Diff; -import org.custommonkey.xmlunit.XMLUnit; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.mdsal.dom.api.DOMNotification; -import org.opendaylight.netconf.api.NetconfMessage; -import org.opendaylight.netconf.api.xml.XmlUtil; -import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil; -import org.opendaylight.netconf.sal.connect.util.MessageCounter; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier; -import org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -public class SchemalessMessageTransformerTest { - - static { - XMLUnit.setIgnoreWhitespace(true); - } - - private static final String EXP_REQUEST = - "\n" - + "\n" - + "aaa\n" - + "\n" - + ""; - private static final String EXP_REPLY = - "\n" - + "aaa\n" - + ""; - private static final String OK_REPLY = "\n" - + "\n" - + "\n"; - - private static final QName TEST_RPC = QName.create("test-ns", "2016-10-13", "test-rpc"); - - private SchemalessMessageTransformer transformer; - - @Before - public void setUp() throws Exception { - transformer = new SchemalessMessageTransformer(new MessageCounter()); - } - - @Test - public void toNotification() throws Exception { - final Document payload = XmlUtil.readXmlToDocument(getClass().getResourceAsStream("/notification-payload.xml")); - final NetconfMessage netconfMessage = new NetconfMessage(payload); - final DOMNotification domNotification = transformer.toNotification(netconfMessage); - assertEquals(domNotification.getType().lastNodeIdentifier(), - SchemalessMessageTransformer.SCHEMALESS_NOTIFICATION_PAYLOAD.getNodeType()); - final QName qName = - QName.create("org:opendaylight:notification:test:ns:yang:user-notification", "user-visited-page"); - final DOMSourceAnyxmlNode dataContainerChild = (DOMSourceAnyxmlNode) domNotification.getBody() - .findChildByArg(new NodeIdentifier(qName)).get(); - final Diff diff = XMLUnit.compareXML(payload, dataContainerChild.body().getNode().getOwnerDocument()); - assertTrue(diff.toString(), diff.similar()); - - } - - @Test - public void toRpcRequest() throws Exception { - final Node src = XmlUtil.readXmlToDocument("aaa"); - final NetconfMessage netconfMessage = transformer.toRpcRequest(TEST_RPC, new DOMSource(src)); - final Diff diff = XMLUnit.compareXML(XmlUtil.readXmlToDocument(EXP_REQUEST), netconfMessage.getDocument()); - assertTrue(diff.toString(), diff.similar()); - } - - @Test - public void toRpcResult() throws Exception { - final Document doc = XmlUtil.readXmlToDocument(EXP_REPLY); - final NetconfMessage netconfMessage = new NetconfMessage(doc); - final DOMSource result = transformer.toRpcResult(RpcResultBuilder.success(netconfMessage).build(), TEST_RPC); - final Document domSourceDoc = (Document) result.getNode(); - final Diff diff = XMLUnit.compareXML(XmlUtil.readXmlToDocument(EXP_REPLY), domSourceDoc); - assertTrue(diff.toString(), diff.similar()); - } - - @Test - public void toEmptyRpcResult() throws Exception { - final Document doc = XmlUtil.readXmlToDocument(OK_REPLY); - final DOMSource result = transformer.toRpcResult(RpcResultBuilder.success(new NetconfMessage(doc)).build(), - NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME); - assertNull(result); - } -}