BUG-459 Remove deprecated NetconfClient class.
[controller.git] / opendaylight / netconf / netconf-it / src / test / java / org / opendaylight / controller / netconf / it / NetconfConfigPersisterITTest.java
index 8bfa0a5846b705d40c8d6e329fbd43adaaf9895e..78933e4b0bededee3245505cf4f30610a4a1c72e 100644 (file)
@@ -22,14 +22,13 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.controller.config.yang.store.api.YangStoreException;
-import org.opendaylight.controller.config.yang.store.impl.HardcodedYangStoreService;
 import org.opendaylight.controller.netconf.api.NetconfMessage;
 import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification;
 import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession;
-import org.opendaylight.controller.netconf.client.NetconfClient;
 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
+import org.opendaylight.controller.netconf.client.test.TestingNetconfClient;
 import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl;
+import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException;
 import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer;
 import org.opendaylight.controller.netconf.impl.NetconfServerDispatcher;
 import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl;
@@ -44,8 +43,6 @@ import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOper
 import org.opendaylight.controller.netconf.persist.impl.ConfigPersisterNotificationHandler;
 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.w3c.dom.Element;
 
 import javax.management.InstanceNotFoundException;
@@ -57,7 +54,6 @@ import java.net.InetSocketAddress;
 import java.util.Collection;
 import java.util.List;
 import java.util.Set;
-import java.util.regex.Pattern;
 
 import static junit.framework.Assert.assertEquals;
 import static org.mockito.Matchers.any;
@@ -69,8 +65,6 @@ import static org.mockito.Mockito.mock;
 
 public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
 
-    private static final Logger logger =  LoggerFactory.getLogger(NetconfConfigPersisterITTest.class);
-
     private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 12023);
 
 
@@ -127,23 +121,23 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
         VerifyingNotificationListener notificationVerifier = createCommitNotificationListener();
         VerifyingPersister mockedAggregator = mockAggregator();
 
-        try (NetconfClient persisterClient = new NetconfClient("persister", tcpAddress, 4000, clientDispatcher)) {
-            ConfigPersisterNotificationHandler configPersisterNotificationHandler = new ConfigPersisterNotificationHandler(
-                    platformMBeanServer, persisterClient, mockedAggregator,
-                    Pattern.compile(""));
-            configPersisterNotificationHandler.init();
-
-            try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, 4000, clientDispatcher)) {
-                NetconfMessage response = netconfClient.sendMessage(loadGetConfigMessage());
-                assertResponse(response, "<modules");
-                assertResponse(response, "<services");
-                response = netconfClient.sendMessage(loadCommitMessage());
-                assertResponse(response, "ok");
-
-                response = netconfClient.sendMessage(loadEditConfigMessage());
-                assertResponse(response, "ok");
-                response = netconfClient.sendMessage(loadCommitMessage());
-                assertResponse(response, "ok");
+        try (TestingNetconfClient persisterClient = new TestingNetconfClient("persister", tcpAddress, 4000, clientDispatcher)) {
+            try (ConfigPersisterNotificationHandler configPersisterNotificationHandler = new ConfigPersisterNotificationHandler(
+                    platformMBeanServer, mockedAggregator)) {
+
+
+                try (TestingNetconfClient netconfClient = new TestingNetconfClient("client", tcpAddress, 4000, clientDispatcher)) {
+                    NetconfMessage response = netconfClient.sendMessage(loadGetConfigMessage());
+                    assertResponse(response, "<modules");
+                    assertResponse(response, "<services");
+                    response = netconfClient.sendMessage(loadCommitMessage());
+                    assertResponse(response, "ok");
+
+                    response = netconfClient.sendMessage(loadEditConfigMessage());
+                    assertResponse(response, "ok");
+                    response = netconfClient.sendMessage(loadCommitMessage());
+                    assertResponse(response, "ok");
+                }
             }
         }
 
@@ -163,7 +157,7 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
 
     private VerifyingNotificationListener createCommitNotificationListener() throws InstanceNotFoundException {
         VerifyingNotificationListener listener = new VerifyingNotificationListener();
-        platformMBeanServer.addNotificationListener(DefaultCommitNotificationProducer.objectName, listener, null, null);
+        platformMBeanServer.addNotificationListener(DefaultCommitNotificationProducer.OBJECT_NAME, listener, null, null);
         return listener;
     }
 
@@ -230,7 +224,7 @@ public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest {
         public VerifyingPersister() throws IOException {
             Persister mockedAggregator = mock(Persister.class);
 
-            doAnswer(new Answer() {
+            doAnswer(new Answer<Object>() {
                 @Override
                 public Object answer(InvocationOnMock invocation) throws Throwable {
                     ConfigSnapshotHolder configSnapshot = (ConfigSnapshotHolder) invocation.getArguments()[0];