X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fit%2FNetconfITMonitoringTest.java;h=79733cc6f5dfd31029eb23cd846f7a4b50bceb8e;hb=refs%2Fchanges%2F13%2F23413%2F26;hp=463b5f045efa9ea1f34a3694198ecc7e26fdd937;hpb=d70f418d19fa09b1efc8fa4ce4ed35f0cf59b73b;p=controller.git diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITMonitoringTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITMonitoringTest.java index 463b5f045e..79733cc6f5 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITMonitoringTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITMonitoringTest.java @@ -8,6 +8,7 @@ package org.opendaylight.controller.netconf.it; import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.doReturn; @@ -26,21 +27,14 @@ import java.util.Collections; import java.util.List; import java.util.Set; import org.junit.Test; +import org.opendaylight.controller.config.util.capability.Capability; +import org.opendaylight.controller.config.util.xml.XmlUtil; import org.opendaylight.controller.netconf.api.NetconfMessage; -import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession; +import org.opendaylight.controller.netconf.api.monitoring.CapabilityListener; import org.opendaylight.controller.netconf.client.TestingNetconfClient; -import org.opendaylight.controller.netconf.impl.osgi.NetconfMonitoringServiceImpl; -import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationServiceSnapshotImpl; -import org.opendaylight.controller.netconf.impl.osgi.SessionMonitoringService; -import org.opendaylight.controller.netconf.mapping.api.Capability; -import org.opendaylight.controller.netconf.mapping.api.NetconfOperationProvider; +import org.opendaylight.controller.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService; -import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory; -import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringActivator; -import org.opendaylight.controller.netconf.monitoring.osgi.NetconfMonitoringOperationService; import org.opendaylight.controller.netconf.util.test.XmlFileLoader; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; -import org.slf4j.Logger; import org.w3c.dom.Document; public class NetconfITMonitoringTest extends AbstractNetconfConfigTest { @@ -49,45 +43,11 @@ public class NetconfITMonitoringTest extends AbstractNetconfConfigTest { public static final InetSocketAddress TCP_ADDRESS = new InetSocketAddress(LOOPBACK_ADDRESS, PORT); public static final TestingCapability TESTING_CAPABILITY = new TestingCapability(); - private NetconfMonitoringServiceImpl netconfMonitoringService; - - @Override - protected void setUpTestInitial() { - netconfMonitoringService = new NetconfMonitoringServiceImpl(getNetconfOperationProvider()); - } - - @Override - protected SessionMonitoringService getNetconfMonitoringService() throws Exception { - return netconfMonitoringService; - } - - @Override - protected Iterable getAdditionalServiceFactories() { - return Collections.singletonList(new NetconfMonitoringActivator.NetconfMonitoringOperationServiceFactory( - new NetconfMonitoringOperationService(netconfMonitoringService))); - } - @Override protected InetSocketAddress getTcpServerAddress() { return TCP_ADDRESS; } - static SessionMonitoringService getNetconfMonitoringListenerService(final Logger LOG, final NetconfMonitoringServiceImpl monitor) { - return new SessionMonitoringService() { - @Override - public void onSessionUp(final NetconfManagementSession session) { - LOG.debug("Management session up {}", session); - monitor.onSessionUp(session); - } - - @Override - public void onSessionDown(final NetconfManagementSession session) { - LOG.debug("Management session down {}", session); - monitor.onSessionDown(session); - } - }; - } - @Test public void testGetResponseFromMonitoring() throws Exception { try (TestingNetconfClient netconfClient = new TestingNetconfClient("client-monitoring", getClientDispatcher(), getClientConfiguration(TCP_ADDRESS, 10000))) { @@ -102,7 +62,6 @@ public class NetconfITMonitoringTest extends AbstractNetconfConfigTest { } } - @Test(timeout = 13 * 10000) public void testClientHelloWithAuth() throws Exception { String fileName = "netconfMessages/client_hello_with_auth.xml"; @@ -151,23 +110,24 @@ public class NetconfITMonitoringTest extends AbstractNetconfConfigTest { assertEquals("Incorrect number of session-id tags in " + XmlUtil.toString(document), i, elementSize); } - public static NetconfOperationProvider getNetconfOperationProvider() { - final NetconfOperationProvider factoriesListener = mock(NetconfOperationProvider.class); - final NetconfOperationServiceSnapshotImpl snap = mock(NetconfOperationServiceSnapshotImpl.class); + public static AggregatedNetconfOperationServiceFactory getNetconfOperationProvider() throws Exception { + final AggregatedNetconfOperationServiceFactory factoriesListener = mock(AggregatedNetconfOperationServiceFactory.class); + final NetconfOperationService snap = mock(NetconfOperationService.class); try { doNothing().when(snap).close(); } catch (final Exception e) { // not happening throw new IllegalStateException(e); } - final NetconfOperationService service = mock(NetconfOperationService.class); final Set caps = Sets.newHashSet(); caps.add(TESTING_CAPABILITY); - doReturn(caps).when(service).getCapabilities(); - final Set services = Sets.newHashSet(service); - doReturn(services).when(snap).getServices(); - doReturn(snap).when(factoriesListener).openSnapshot(anyString()); + doReturn(caps).when(factoriesListener).getCapabilities(); + doReturn(snap).when(factoriesListener).createService(anyString()); + + AutoCloseable mock = mock(AutoCloseable.class); + doNothing().when(mock).close(); + doReturn(mock).when(factoriesListener).registerCapabilityListener(any(CapabilityListener.class)); return factoriesListener; } @@ -199,8 +159,8 @@ public class NetconfITMonitoringTest extends AbstractNetconfConfigTest { } @Override - public Optional> getLocation() { - return Optional.absent(); + public List getLocation() { + return Collections.emptyList(); } } }