use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult 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.spi.DefaultDOMRpcResult 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.spi.DefaultDOMRpcResult 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.spi.DefaultDOMRpcResult 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());
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project mdsal by opendaylight.
the class Mdsal500Test method testDOMRegistrationWithBindingInvocation.
@Test
public void testDOMRegistrationWithBindingInvocation() throws InterruptedException, ExecutionException, TimeoutException {
SwitchOutput baSwitchOutput = new SwitchOutputBuilder().build();
biRpcProviderService.registerRpcImplementation((rpc, input) -> FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(testContext.getCodec().currentSerializer().toNormalizedNodeRpcData(baSwitchOutput))), DOMRpcIdentifier.create(SWITCH_QNAME));
final Mdsal500Service baSwitchService = baRpcConsumerService.getRpcService(Mdsal500Service.class);
Future<RpcResult<SwitchOutput>> baResult = baSwitchService.switch$(switchBuilder(FOO).build());
assertNotNull(baResult);
assertEquals(baSwitchOutput, baResult.get(5, TimeUnit.SECONDS).getResult());
}
Aggregations