Search in sources :

Example 6 with DOMRpcException

use of org.opendaylight.controller.md.sal.dom.api.DOMRpcException in project controller by opendaylight.

the class RemoteRpcImplementationTest 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) ArgumentCaptor.forClass(NormalizedNode.class);
    when(domRpcService2.invokeRpc(eq(TEST_RPC_TYPE), inputCaptor.capture())).thenReturn(Futures.<DOMRpcResult, DOMRpcException>immediateCheckedFuture(rpcResult));
    final CheckedFuture<DOMRpcResult, DOMRpcException> frontEndFuture = remoteRpcImpl1.invokeRpc(TEST_RPC_ID, invokeRpcInput);
    assertTrue(frontEndFuture instanceof RemoteDOMRpcFuture);
    final DOMRpcResult result = frontEndFuture.checkedGet(5, TimeUnit.SECONDS);
    assertEquals(rpcOutput, result.getResult());
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ArgumentCaptor(org.mockito.ArgumentCaptor) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) DOMRpcException(org.opendaylight.controller.md.sal.dom.api.DOMRpcException) Test(org.junit.Test)

Aggregations

DOMRpcException (org.opendaylight.controller.md.sal.dom.api.DOMRpcException)6 Test (org.junit.Test)5 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)5 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)5 DefaultDOMRpcResult (org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult)4 ArgumentCaptor (org.mockito.ArgumentCaptor)3 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)3 DOMRpcImplementationNotAvailableException (org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException)2 Failure (akka.actor.Status.Failure)1 TestKit (akka.testkit.javadsl.TestKit)1 MountPoint (org.opendaylight.controller.md.sal.binding.api.MountPoint)1 DOMRpcAvailabilityListener (org.opendaylight.controller.md.sal.dom.api.DOMRpcAvailabilityListener)1 DOMRpcImplementation (org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementation)1 DOMRpcService (org.opendaylight.controller.md.sal.dom.api.DOMRpcService)1 ExecuteRpc (org.opendaylight.controller.remote.rpc.messages.ExecuteRpc)1 RpcConsumerRegistry (org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry)1 OpendaylightTestRpcServiceService (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.OpendaylightTestRpcServiceService)1 RockTheHouseInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.rpcservice.rev140701.RockTheHouseInputBuilder)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1