X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRpcBrokerTest.java;h=7ea9191e7c7d4d07e868d94345197ea224b35978;hp=02d46319e9fb022581ef97a3e0c254a178d83317;hb=a4fcc7debbd036c6e1df8c88df1c0268c62e76e4;hpb=c11dae56ca449d754db98fb8de194594c84d1f24 diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java index 02d46319e9..7ea9191e7c 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcBrokerTest.java @@ -5,67 +5,55 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.controller.remote.rpc; import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.eq; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; import akka.actor.Status.Failure; -import akka.testkit.JavaTestKit; -import com.google.common.util.concurrent.Futures; -import org.junit.Assert; +import java.time.Duration; import org.junit.Test; -import org.mockito.Mockito; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcImplementationNotAvailableException; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.spi.DefaultDOMRpcResult; import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc; import org.opendaylight.controller.remote.rpc.messages.RpcResponse; +import org.opendaylight.mdsal.dom.api.DOMRpcException; +import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult; +import org.opendaylight.yangtools.util.concurrent.FluentFutures; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; -import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode; public class RpcBrokerTest extends AbstractRpcTest { @Test public void testExecuteRpc() { - new JavaTestKit(node1) { - { - - final ContainerNode invokeRpcResult = makeRPCOutput("bar"); - final DOMRpcResult rpcResult = new DefaultDOMRpcResult(invokeRpcResult); - when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.>any())).thenReturn( - Futures.immediateCheckedFuture(rpcResult)); + final ContainerNode invokeRpcResult = makeRPCOutput("bar"); + final DOMRpcResult rpcResult = new DefaultDOMRpcResult(invokeRpcResult); + when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), any())).thenReturn( + FluentFutures.immediateFluentFuture(rpcResult)); - final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null); + final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null); - rpcInvoker1.tell(executeMsg, getRef()); + rpcInvoker1.tell(executeMsg, rpcRegistry1Probe.getRef()); - final RpcResponse rpcResponse = expectMsgClass(duration("5 seconds"), RpcResponse.class); + final RpcResponse rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), RpcResponse.class); - assertEquals(rpcResult.getResult(), rpcResponse.getResultNormalizedNode()); - } - }; + assertEquals(rpcResult.getResult(), rpcResponse.getResultNormalizedNode()); } @Test public void testExecuteRpcFailureWithException() { - new JavaTestKit(node1) { - { - when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), Mockito.>any())) - .thenReturn(Futures.immediateFailedCheckedFuture( - new DOMRpcImplementationNotAvailableException("NOT FOUND"))); + when(domRpcService1.invokeRpc(eq(TEST_RPC_TYPE), any())).thenReturn(FluentFutures.immediateFailedFluentFuture( + new DOMRpcImplementationNotAvailableException("NOT FOUND"))); - final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null); + final ExecuteRpc executeMsg = ExecuteRpc.from(TEST_RPC_ID, null); - rpcInvoker1.tell(executeMsg, getRef()); + rpcInvoker1.tell(executeMsg, rpcRegistry1Probe.getRef()); - final Failure rpcResponse = expectMsgClass(duration("5 seconds"), akka.actor.Status.Failure.class); + final Failure rpcResponse = rpcRegistry1Probe.expectMsgClass(Duration.ofSeconds(5), Failure.class); - Assert.assertTrue(rpcResponse.cause() instanceof DOMRpcException); - } - }; + assertTrue(rpcResponse.cause() instanceof DOMRpcException); } }