Search in sources :

Example 1 with ExecuteRpc

use of org.opendaylight.controller.remote.rpc.messages.ExecuteRpc in project controller by opendaylight.

the class RpcBrokerTest method testExecuteRpcFailureWithException.

@Test
public void testExecuteRpcFailureWithException() {
    new TestKit(node1) {

        {
            when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.<NormalizedNode<?, ?>>any())).thenReturn(Futures.<DOMRpcResult, DOMRpcException>immediateFailedCheckedFuture(new DOMRpcImplementationNotAvailableException("NOT FOUND")));
            final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
            rpcInvoker1.tell(executeMsg, getRef());
            final Failure rpcResponse = expectMsgClass(duration("5 seconds"), akka.actor.Status.Failure.class);
            Assert.assertTrue(rpcResponse.cause() instanceof DOMRpcException);
        }
    };
}
Also used : DOMRpcImplementationNotAvailableException(org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException) ExecuteRpc(org.opendaylight.controller.remote.rpc.messages.ExecuteRpc) TestKit(akka.testkit.javadsl.TestKit) DOMRpcException(org.opendaylight.controller.md.sal.dom.api.DOMRpcException) Failure(akka.actor.Status.Failure) Test(org.junit.Test)

Example 2 with ExecuteRpc

use of org.opendaylight.controller.remote.rpc.messages.ExecuteRpc in project controller by opendaylight.

the class RpcBrokerTest method testExecuteRpc.

@Test
public void testExecuteRpc() {
    new TestKit(node1) {

        {
            final ContainerNode invokeRpcResult = makeRPCOutput("bar");
            final DOMRpcResult rpcResult = new DefaultDOMRpcResult(invokeRpcResult);
            when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.<NormalizedNode<?, ?>>any())).thenReturn(Futures.<DOMRpcResult, DOMRpcException>immediateCheckedFuture(rpcResult));
            final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null);
            rpcInvoker1.tell(executeMsg, getRef());
            final RpcResponse rpcResponse = expectMsgClass(duration("5 seconds"), RpcResponse.class);
            assertEquals(rpcResult.getResult(), rpcResponse.getResultNormalizedNode());
        }
    };
}
Also used : DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.controller.md.sal.dom.api.DOMRpcResult) DefaultDOMRpcResult(org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult) ExecuteRpc(org.opendaylight.controller.remote.rpc.messages.ExecuteRpc) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) TestKit(akka.testkit.javadsl.TestKit) RpcResponse(org.opendaylight.controller.remote.rpc.messages.RpcResponse) Test(org.junit.Test)

Aggregations

TestKit (akka.testkit.javadsl.TestKit)2 Test (org.junit.Test)2 ExecuteRpc (org.opendaylight.controller.remote.rpc.messages.ExecuteRpc)2 Failure (akka.actor.Status.Failure)1 DOMRpcException (org.opendaylight.controller.md.sal.dom.api.DOMRpcException)1 DOMRpcImplementationNotAvailableException (org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException)1 DOMRpcResult (org.opendaylight.controller.md.sal.dom.api.DOMRpcResult)1 DefaultDOMRpcResult (org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult)1 RpcResponse (org.opendaylight.controller.remote.rpc.messages.RpcResponse)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1