Search in sources :

Example 11 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class SchemalessNetconfDeviceRpcTest method setUp.

@Before
public void setUp() throws Exception {
    RpcResult<NetconfMessage> msg = null;
    ListenableFuture<RpcResult<NetconfMessage>> future = Futures.immediateFuture(msg);
    doReturn(future).when(listener).sendRequest(any(), any());
    final MessageCounter counter = new MessageCounter();
    deviceRpc = new SchemalessNetconfDeviceRpc(new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830)), listener, new BaseRpcSchemalessTransformer(BASE_SCHEMAS, counter), new SchemalessMessageTransformer(counter));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) MessageCounter(org.opendaylight.netconf.sal.connect.util.MessageCounter) SchemalessMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BaseRpcSchemalessTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseRpcSchemalessTransformer) Before(org.junit.Before)

Example 12 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class ReadOnlyTxTest method testExists.

@Test
public void testExists() throws Exception {
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
    final ReadOnlyTx readOnlyTx = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
    readOnlyTx.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
    verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
    readOnlyTx.exists(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
    verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME), any(ContainerNode.class));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) InetSocketAddress(java.net.InetSocketAddress) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 13 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class ReadOnlyTxTest method testIdentifier.

@Test
public void testIdentifier() throws Exception {
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
    final ReadOnlyTx tx1 = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
    final ReadOnlyTx tx2 = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
    Assert.assertNotEquals(tx1.getIdentifier(), tx2.getIdentifier());
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) InetSocketAddress(java.net.InetSocketAddress) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 14 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class ReadOnlyTxTest method testRead.

@Test
public void testRead() throws Exception {
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
    final ReadOnlyTx readOnlyTx = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
    readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
    verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
    readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
    verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME), any(ContainerNode.class));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) InetSocketAddress(java.net.InetSocketAddress) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 15 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class YangLibrarySchemaYangSourceProviderTest method testGetSourceFailure.

@Test
public void testGetSourceFailure() throws InterruptedException, MalformedURLException {
    final URL url = new URL("http://non-existing-entity.yang");
    final Map<SourceIdentifier, URL> sourceIdentifierURLMap = Collections.singletonMap(workingSid, url);
    final RemoteDeviceId id = new RemoteDeviceId("id", new InetSocketAddress("localhost", 22));
    final YangLibrarySchemaYangSourceProvider failingYangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(id, sourceIdentifierURLMap);
    final ListenableFuture<?> future = failingYangLibrarySchemaYangSourceProvider.getSource(workingSid);
    final ExecutionException ex = assertThrows(ExecutionException.class, () -> future.get());
    assertThat(ex.getCause(), instanceOf(SchemaSourceException.class));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) SchemaSourceException(org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) ExecutionException(java.util.concurrent.ExecutionException) URL(java.net.URL) Test(org.junit.Test)

Aggregations

RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)26 InetSocketAddress (java.net.InetSocketAddress)15 Test (org.junit.Test)11 Before (org.junit.Before)10 NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)7 EmptyMountPointContext (org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext)6 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)5 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)5 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)5 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)4 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 NetconfTopologySetup (org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 URL (java.net.URL)2 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)2 NetconfDeviceCommunicator (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator)2 SchemalessMessageTransformer (org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer)2 Host (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host)2 NetconfNode (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode)2 QName (org.opendaylight.yangtools.yang.common.QName)2