use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project controller by opendaylight.
the class RemoteOpsImplementationTest method testInvokeRpcWithRemoteFailedFuture.
/**
* This test method invokes and executes the remote rpc.
*/
@SuppressWarnings({ "checkstyle:AvoidHidingCauseException", "checkstyle:IllegalThrows" })
@Test(expected = DOMRpcException.class)
public void testInvokeRpcWithRemoteFailedFuture() throws Throwable {
final NormalizedNode invokeRpcInput = makeRPCInput("foo");
@SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<NormalizedNode> inputCaptor = (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class);
when(domRpcService2.invokeRpc(eq(TEST_RPC), inputCaptor.capture())).thenReturn(FluentFutures.immediateFailedFluentFuture(new RemoteDOMRpcException("Test Exception", null)));
final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
try {
frontEndFuture.get(5, TimeUnit.SECONDS);
} catch (ExecutionException e) {
throw e.getCause();
}
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project controller by opendaylight.
the class RemoteOpsImplementationTest method testInvokeRpcWithNoOutput.
/**
* This test method invokes and executes the remote rpc.
*/
@Test
public void testInvokeRpcWithNoOutput() throws Exception {
final ContainerNode rpcOutput = null;
final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput);
final NormalizedNode invokeRpcInput = makeRPCInput("foo");
@SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<NormalizedNode> inputCaptor = (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class);
doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2).invokeRpc(eq(TEST_RPC), inputCaptor.capture());
final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
assertNull(result.getResult());
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project controller by opendaylight.
the class RemoteOpsImplementationTest method testInvokeRpc.
/**
* This test method invokes and executes the remote rpc.
*/
@Test
public void testInvokeRpc() throws Exception {
final ContainerNode rpcOutput = makeRPCOutput("bar");
final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput);
final NormalizedNode invokeRpcInput = makeRPCInput("foo");
@SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<NormalizedNode> inputCaptor = ArgumentCaptor.forClass(NormalizedNode.class);
doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2).invokeRpc(eq(TEST_RPC), inputCaptor.capture());
final ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
assertEquals(rpcOutput, result.getResult());
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project controller by opendaylight.
the class RemoteOpsImplementationTest method testInvokeRpcWithNullInput.
/**
* This test method invokes and executes the remote rpc.
*/
@Test
public void testInvokeRpcWithNullInput() throws Exception {
final ContainerNode rpcOutput = makeRPCOutput("bar");
final DOMRpcResult rpcResult = new DefaultDOMRpcResult(rpcOutput);
@SuppressWarnings({ "unchecked", "rawtypes" }) final ArgumentCaptor<NormalizedNode> inputCaptor = (ArgumentCaptor) ArgumentCaptor.forClass(NormalizedNode.class);
doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService2).invokeRpc(eq(TEST_RPC), inputCaptor.capture());
ListenableFuture<DOMRpcResult> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, null);
assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
final DOMRpcResult result = frontEndFuture.get(5, TimeUnit.SECONDS);
assertEquals(rpcOutput, result.getResult());
}
use of org.opendaylight.mdsal.dom.api.DOMRpcResult in project controller by opendaylight.
the class OpsBrokerTest method testExecuteRpc.
@Test
public void testExecuteRpc() {
final ContainerNode invokeRpcResult = makeRPCOutput("bar");
final DOMRpcResult rpcResult = new DefaultDOMRpcResult(invokeRpcResult);
doReturn(FluentFutures.immediateFluentFuture(rpcResult)).when(domRpcService1).invokeRpc(eq(TEST_RPC), any());
final ExecuteRpc executeRpc = ExecuteRpc.from(TEST_RPC_ID, null);
rpcInvoker1.tell(executeRpc, rpcRegistry1Probe.getRef());
final RpcResponse rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), RpcResponse.class);
assertEquals(rpcResult.getResult(), rpcResponse.getOutput());
}
Aggregations