use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfTopologyUtilTest method testCreateRemoteDeviceId.
@Test
public void testCreateRemoteDeviceId() {
final Host host = new Host(new IpAddress(new Ipv4Address("127.0.0.1")));
final NetconfNode netconfNode = new NetconfNodeBuilder().setHost(host).setPort(new PortNumber(Uint16.valueOf(9999))).build();
final NodeId nodeId = new NodeId("testing-node");
final RemoteDeviceId id = NetconfTopologyUtils.createRemoteDeviceId(nodeId, netconfNode);
assertEquals("testing-node", id.getName());
assertEquals(host, id.getHost());
assertEquals(9999, id.getAddress().getPort());
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class FieldsAwareReadOnlyTxTest method testReadWithFields.
@Test
public void testReadWithFields() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(mockedNode))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
try (FieldsAwareReadOnlyTx readOnlyTx = new FieldsAwareReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)))) {
readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty(), List.of(YangInstanceIdentifier.empty()));
verify(rpc).invokeRpc(eq(NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
verify(rpc).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class));
}
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfBaseOpsTest method setUp.
@Before
public void setUp() throws Exception {
final InputStream okStream = getClass().getResourceAsStream("/netconfMessages/rpc-reply_ok.xml");
final InputStream dataStream = getClass().getResourceAsStream("/netconfMessages/rpc-reply_get.xml");
final NetconfMessage ok = new NetconfMessage(XmlUtil.readXmlToDocument(okStream));
final NetconfMessage data = new NetconfMessage(XmlUtil.readXmlToDocument(dataStream));
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME))).thenReturn(RpcResultBuilder.success(data).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME))).thenReturn(RpcResultBuilder.success(data).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_VALIDATE_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
final MessageTransformer<NetconfMessage> transformer = new NetconfMessageTransformer(new EmptyMountPointContext(SCHEMA_CONTEXT), true, BASE_SCHEMAS.getBaseSchema());
final DOMRpcService rpc = new NetconfDeviceRpc(SCHEMA_CONTEXT, listener, transformer);
final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
callback = new NetconfRpcFutureCallback("prefix", id);
baseOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class RemoteDeviceIdTest method testEquals.
@Test
public void testEquals() {
final InetSocketAddress address = new InetSocketAddress("127.0.0.1", 8000);
final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test", address);
final RemoteDeviceId remoteDeviceIdEqualName = new RemoteDeviceId("test", address);
final RemoteDeviceId remoteDeviceIdDiffName = new RemoteDeviceId("test-diff", address);
assertEquals(true, remoteDeviceId.equals(remoteDeviceId));
assertEquals(false, remoteDeviceId.equals(this));
assertEquals(false, remoteDeviceId.equals(remoteDeviceIdDiffName));
assertEquals(true, remoteDeviceId.equals(remoteDeviceIdEqualName));
}
use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.
the class NetconfDeviceDataBrokerTest method getDataBroker.
private NetconfDeviceDataBroker getDataBroker(final String... caps) {
NetconfSessionPreferences prefs = NetconfSessionPreferences.fromStrings(Arrays.asList(caps));
final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
return new NetconfDeviceDataBroker(id, new EmptyMountPointContext(SCHEMA_CONTEXT), rpcService, prefs);
}
Aggregations