use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class WriteCandidateRunningTxTest method setUp.
@Before
public void setUp() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
netconfOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class WriteCandidateTxTest method setUp.
@Before
public void setUp() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
netconfOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class WriteRunningTxTest method setUp.
@Before
public void setUp() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
netconfOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfRemoteSchemaYangSourceProviderTest method setUp.
@Before
public void setUp() throws Exception {
final DOMRpcResult value = new DefaultDOMRpcResult(getNode(), Set.of());
final FluentFuture<DOMRpcResult> response = FluentFutures.immediateFluentFuture(value);
doReturn(response).when(service).invokeRpc(any(QName.class), any(ContainerNode.class));
provider = new NetconfRemoteSchemaYangSourceProvider(new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("localhost", 17830)), service);
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfNodeActorTest method testSlaveInvokeRpc.
@Test
public void testSlaveInvokeRpc() throws Exception {
final List<SourceIdentifier> sourceIdentifiers = Lists.newArrayList(RevisionSourceIdentifier.create("testID"));
initializeMaster(sourceIdentifiers);
registerSlaveMountPoint();
ArgumentCaptor<DOMRpcService> domRPCServiceCaptor = ArgumentCaptor.forClass(DOMRpcService.class);
verify(mockMountPointBuilder).addService(eq(DOMRpcService.class), domRPCServiceCaptor.capture());
final DOMRpcService slaveDomRPCService = domRPCServiceCaptor.getValue();
assertTrue(slaveDomRPCService instanceof ProxyDOMRpcService);
final QName testQName = QName.create("", "TestQname");
final NormalizedNode outputNode = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(testQName)).withChild(ImmutableNodes.leafNode(testQName, "foo")).build();
final RpcError rpcError = RpcResultBuilder.newError(RpcError.ErrorType.RPC, null, "Rpc invocation failed.");
// RPC with no response output.
doReturn(FluentFutures.immediateNullFluentFuture()).when(mockDOMRpcService).invokeRpc(any(), any());
DOMRpcResult result = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS);
assertEquals(null, result);
// RPC with response output.
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(outputNode))).when(mockDOMRpcService).invokeRpc(any(), any());
result = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS);
assertEquals(outputNode, result.getResult());
assertTrue(result.getErrors().isEmpty());
// RPC with response error.
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(rpcError))).when(mockDOMRpcService).invokeRpc(any(), any());
result = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS);
assertNull(result.getResult());
assertEquals(rpcError, result.getErrors().iterator().next());
// RPC with response output and error.
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(outputNode, rpcError))).when(mockDOMRpcService).invokeRpc(any(), any());
final DOMRpcResult resultOutputError = slaveDomRPCService.invokeRpc(testQName, outputNode).get(2, TimeUnit.SECONDS);
assertEquals(outputNode, resultOutputError.getResult());
assertEquals(rpcError, resultOutputError.getErrors().iterator().next());
// RPC failure.
doReturn(FluentFutures.immediateFailedFluentFuture(new ClusteringRpcException("mock"))).when(mockDOMRpcService).invokeRpc(any(), any());
final ListenableFuture<? extends DOMRpcResult> future = slaveDomRPCService.invokeRpc(testQName, outputNode);
final ExecutionException e = assertThrows(ExecutionException.class, () -> future.get(2, TimeUnit.SECONDS));
final Throwable cause = e.getCause();
assertThat(cause, instanceOf(DOMRpcException.class));
assertEquals("mock", cause.getMessage());
}
Aggregations