Bug 8153: Enforce check-style rules for netconf - sal-netconf-connector
[netconf.git] / netconf / sal-netconf-connector / src / test / java / org / opendaylight / netconf / sal / connect / netconf / sal / SchemalessNetconfDeviceRpcTest.java
index 575b7b96994d92307d8b8f9f9f309b9d13376a4b..8448e9372aa16ec73ab8a88fe859a7d417d56676 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * 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.sal;
 
 import static org.mockito.Matchers.any;
@@ -16,6 +23,9 @@ import org.mockito.MockitoAnnotations;
 import org.opendaylight.controller.config.util.xml.XmlUtil;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceCommunicator;
+import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseRpcSchemalessTransformer;
+import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer;
+import org.opendaylight.netconf.sal.connect.util.MessageCounter;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -23,9 +33,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SchemalessNetconfDeviceRpcTest {
 
+    private static final Logger LOG = LoggerFactory.getLogger(SchemalessNetconfDeviceRpcTest.class);
+
     @Mock
     private RemoteDeviceCommunicator<NetconfMessage> listener;
 
@@ -37,7 +51,10 @@ public class SchemalessNetconfDeviceRpcTest {
         RpcResult<NetconfMessage> msg = null;
         ListenableFuture<RpcResult<NetconfMessage>> future = Futures.immediateFuture(msg);
         doReturn(future).when(listener).sendRequest(any(), any());
-        deviceRpc = new SchemalessNetconfDeviceRpc(new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830)), listener);
+        final MessageCounter counter = new MessageCounter();
+        deviceRpc = new SchemalessNetconfDeviceRpc(
+                new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830)), listener,
+                new BaseRpcSchemalessTransformer(counter), new SchemalessMessageTransformer(counter));
 
     }
 
@@ -45,17 +62,17 @@ public class SchemalessNetconfDeviceRpcTest {
     public void testInvokeRpc() throws Exception {
         final QName qName = QName.create("urn:ietf:params:xml:ns:netconf:base:1.0", "2011-06-01", "get-config");
         SchemaPath type = SchemaPath.create(true, qName);
-        DOMSource src = new DOMSource(XmlUtil.readXmlToDocument("<get-config xmlns=\"dd\">\n" +
-                "    <source>\n" +
-                "      <running/>\n" +
-                "    </source>\n" +
-                "    <filter type=\"subtree\">\n" +
-                "      <mainroot xmlns=\"urn:dummy:mod-0\">\n" +
-                "        <maincontent/>\n" +
-                "<choiceList></choiceList>\n" +
-                "      </mainroot>\n" +
-                "    </filter>\n" +
-                "  </get-config>"));
+        DOMSource src = new DOMSource(XmlUtil.readXmlToDocument("<get-config xmlns=\"dd\">\n"
+                + "    <source>\n"
+                + "      <running/>\n"
+                + "    </source>\n"
+                + "    <filter type=\"subtree\">\n"
+                + "      <mainroot xmlns=\"urn:dummy:mod-0\">\n"
+                + "        <maincontent/>\n"
+                + "<choiceList></choiceList>\n"
+                + "      </mainroot>\n"
+                + "    </filter>\n"
+                "  </get-config>"));
         NormalizedNode<?, ?> input = Builders.anyXmlBuilder()
                 .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(qName))
                 .withValue(src)
@@ -63,8 +80,8 @@ public class SchemalessNetconfDeviceRpcTest {
 
         deviceRpc.invokeRpc(type, input);
         ArgumentCaptor<NetconfMessage> msgCaptor = ArgumentCaptor.forClass(NetconfMessage.class);
-        ArgumentCaptor<QName> qNameCaptor = ArgumentCaptor.forClass(QName.class);
-        verify(listener).sendRequest(msgCaptor.capture(), qNameCaptor.capture());
-        System.out.println(XmlUtil.toString(msgCaptor.getValue().getDocument()));
+        ArgumentCaptor<QName> qnameCaptor = ArgumentCaptor.forClass(QName.class);
+        verify(listener).sendRequest(msgCaptor.capture(), qnameCaptor.capture());
+        LOG.info(XmlUtil.toString(msgCaptor.getValue().getDocument()));
     }
-}
\ No newline at end of file
+}