X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRemoteRpcProviderTest.java;h=e8ea373d4834ba072cf8e17cd6541c6a76aadffc;hb=9ddc65e1ddae50f691566cd9382707679436c055;hp=5cd3df3a245d0d645059f26637d68b6587fc3af0;hpb=e631dc96f0461b2270377dc072b9f969a875667a;p=controller.git diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java index 5cd3df3a24..e8ea373d48 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderTest.java @@ -10,29 +10,61 @@ package org.opendaylight.controller.remote.rpc; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.testkit.JavaTestKit; import com.typesafe.config.Config; +import java.util.concurrent.TimeUnit; import org.junit.AfterClass; +import org.junit.Assert; import org.junit.BeforeClass; +import org.junit.Test; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; +import org.opendaylight.controller.sal.core.api.Broker; +import org.opendaylight.controller.sal.core.api.model.SchemaService; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import scala.concurrent.Await; +import scala.concurrent.duration.Duration; public class RemoteRpcProviderTest { + static ActorSystem system; + static RemoteRpcProviderConfig moduleConfig; + + @BeforeClass + public static void setup() throws InterruptedException { + moduleConfig = new RemoteRpcProviderConfig.Builder("odl-cluster-rpc").build(); + final Config config = moduleConfig.get(); + system = ActorSystem.create("odl-cluster-rpc", config); + + } - static ActorSystem system; - static RemoteRpcProviderConfig moduleConfig; + @AfterClass + public static void teardown() { + JavaTestKit.shutdownActorSystem(system); + system = null; + } - @BeforeClass - public static void setup() throws InterruptedException { - moduleConfig = new RemoteRpcProviderConfig.Builder("odl-cluster-rpc").build(); - final Config config = moduleConfig.get(); - system = ActorSystem.create("odl-cluster-rpc", config); + @Test + public void testRemoteRpcProvider() throws Exception { + try (final RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(DOMRpcProviderService.class), + new RemoteRpcProviderConfig(system.settings().config()))) { + final Broker.ProviderSession session = mock(Broker.ProviderSession.class); + final SchemaService schemaService = mock(SchemaService.class); + when(schemaService.getGlobalContext()).thenReturn(mock(SchemaContext.class)); + when(session.getService(SchemaService.class)).thenReturn(schemaService); + when(session.getService(DOMRpcService.class)).thenReturn(mock(DOMRpcService.class)); - } + rpcProvider.onSessionInitiated(session); - @AfterClass - public static void teardown() { - JavaTestKit.shutdownActorSystem(system); - system = null; - } + final ActorRef actorRef = Await.result( + system.actorSelection(moduleConfig.getRpcManagerPath()).resolveOne( + Duration.create(1, TimeUnit.SECONDS)), Duration.create(2, TimeUnit.SECONDS)); + Assert.assertTrue(actorRef.path().toString().contains(moduleConfig.getRpcManagerPath())); + } + } }