X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-netconf-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fconnect%2Fnetconf%2FNetconfDeviceTest.java;h=34972dffe2d4f09493e8b3bf5bba08557a00c552;hb=e433e0aa67cc6d144cd3d8d6117de864eb7ebf97;hp=0f643789ecc64cb9bb6b662054878775b8a337af;hpb=f84f3b8fb24b1ee2074fbbb3f5c64e3ba3191e3e;p=controller.git diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java index 0f643789ec..34972dffe2 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java @@ -19,7 +19,9 @@ import static org.mockito.Mockito.verify; import com.google.common.base.Optional; import com.google.common.collect.HashMultimap; +import com.google.common.collect.Iterables; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import com.google.common.util.concurrent.Futures; import java.io.InputStream; import java.util.ArrayList; @@ -33,6 +35,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import org.opendaylight.controller.md.sal.dom.api.DOMNotification; import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; @@ -46,6 +49,7 @@ import org.opendaylight.controller.sal.connect.netconf.listener.NetconfSessionPr import org.opendaylight.controller.sal.connect.netconf.sal.NetconfDeviceRpc; import org.opendaylight.controller.sal.connect.netconf.util.NetconfMessageTransformUtil; import org.opendaylight.controller.sal.connect.util.RemoteDeviceId; +import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; import org.opendaylight.yangtools.yang.model.api.Module; @@ -132,6 +136,7 @@ public class NetconfDeviceTest { public void testNetconfDeviceMissingSource() throws Exception { final RemoteDeviceHandler facade = getFacade(); final NetconfDeviceCommunicator listener = getListener(); + final SchemaContext schema = getSchema(); final SchemaContextFactory schemaFactory = getSchemaFactory(); @@ -143,13 +148,23 @@ public class NetconfDeviceTest { if(((Collection) invocation.getArguments()[0]).size() == 2) { return Futures.immediateFailedCheckedFuture(schemaResolutionException); } else { - return Futures.immediateCheckedFuture(getSchema()); + return Futures.immediateCheckedFuture(schema); } } }).when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class)); final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO - = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), schemaFactory, stateSchemasResolver); + = new NetconfDevice.SchemaResourcesDTO(getSchemaRegistry(), schemaFactory, new NetconfStateSchemas.NetconfStateSchemasResolver() { + @Override + public NetconfStateSchemas resolve(final NetconfDeviceRpc deviceRpc, final NetconfSessionPreferences remoteSessionCapabilities, final RemoteDeviceId id) { + final Module first = Iterables.getFirst(schema.getModules(), null); + final QName qName = QName.create(first.getQNameModule(), first.getName()); + final NetconfStateSchemas.RemoteYangSchema source1 = new NetconfStateSchemas.RemoteYangSchema(qName); + final NetconfStateSchemas.RemoteYangSchema source2 = new NetconfStateSchemas.RemoteYangSchema(QName.create(first.getQNameModule(), "test-module2")); + return new NetconfStateSchemas(Sets.newHashSet(source1, source2)); + } + }); + final NetconfDevice device = new NetconfDevice(schemaResourcesDTO, getId(), facade, getExecutor(), true); // Monitoring supported final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY, TEST_CAPABILITY2)); @@ -179,7 +194,7 @@ public class NetconfDeviceTest { device.onNotification(notification); device.onNotification(notification); - verify(facade, times(0)).onNotification(any(ContainerNode.class)); + verify(facade, times(0)).onNotification(any(DOMNotification.class)); final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_CAPABILITY)); @@ -188,10 +203,10 @@ public class NetconfDeviceTest { device.handleSalInitializationSuccess(NetconfToNotificationTest.getNotificationSchemaContext(getClass()), sessionCaps, deviceRpc); - verify(facade, timeout(10000).times(2)).onNotification(any(ContainerNode.class)); + verify(facade, timeout(10000).times(2)).onNotification(any(DOMNotification.class)); device.onNotification(notification); - verify(facade, timeout(10000).times(3)).onNotification(any(ContainerNode.class)); + verify(facade, timeout(10000).times(3)).onNotification(any(DOMNotification.class)); } @Test @@ -239,7 +254,7 @@ public class NetconfDeviceTest { final RemoteDeviceHandler remoteDeviceHandler = mockCloseableClass(RemoteDeviceHandler.class); doNothing().when(remoteDeviceHandler).onDeviceConnected(any(SchemaContext.class), any(NetconfSessionPreferences.class), any(NetconfDeviceRpc.class)); doNothing().when(remoteDeviceHandler).onDeviceDisconnected(); - doNothing().when(remoteDeviceHandler).onNotification(any(ContainerNode.class)); + doNothing().when(remoteDeviceHandler).onNotification(any(DOMNotification.class)); return remoteDeviceHandler; }