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%2FRemoteRpcProviderTest.java;h=a5158bc94db0dc76cd36a781680bd97e355219af;hp=8a7e4a039846205846e1b54b21981f78af843783;hb=c11dae56ca449d754db98fb8de194594c84d1f24;hpb=641dd738c5c64121b7f7816dcef3b766051d1196 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 8a7e4a0398..a5158bc94d 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 @@ -1,61 +1,61 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * 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.mockito.Mockito.mock; import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.testkit.JavaTestKit; +import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; +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.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; import scala.concurrent.Await; import scala.concurrent.duration.Duration; -import java.util.concurrent.TimeUnit; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - public class RemoteRpcProviderTest { - - static ActorSystem system; - - - @BeforeClass - public static void setup() throws InterruptedException { - system = ActorSystem.create("odl-cluster-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc")); - } - - @AfterClass - public static void teardown() { - JavaTestKit.shutdownActorSystem(system); - system = null; - } - - @Test - public void testRemoteRpcProvider() throws Exception { - RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(RpcProvisionRegistry.class)); - Broker.ProviderSession session = mock(Broker.ProviderSession.class); - SchemaService schemaService = mock(SchemaService.class); - when(schemaService.getGlobalContext()). thenReturn(mock(SchemaContext.class)); - when(session.getService(SchemaService.class)).thenReturn(schemaService); - rpcProvider.onSessionInitiated(session); - ActorRef actorRef = Await.result(system.actorSelection(ActorConstants.RPC_MANAGER_PATH).resolveOne(Duration.create(1, TimeUnit.SECONDS)), - Duration.create(2, TimeUnit.SECONDS)); - Assert.assertTrue(actorRef.path().toString().contains(ActorConstants.RPC_MANAGER_PATH)); - } + static ActorSystem system; + static RemoteRpcProviderConfig moduleConfig; + + @BeforeClass + public static void setup() throws InterruptedException { + moduleConfig = new RemoteRpcProviderConfig.Builder("odl-cluster-rpc") + .withConfigReader(ConfigFactory::load).build(); + final Config config = moduleConfig.get(); + system = ActorSystem.create("odl-cluster-rpc", config); + + } + + @AfterClass + public static void teardown() { + JavaTestKit.shutdownActorSystem(system); + system = null; + } + + @Test + public void testRemoteRpcProvider() throws Exception { + try (RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(DOMRpcProviderService.class), + mock(DOMRpcService.class), new RemoteRpcProviderConfig(system.settings().config()))) { + + rpcProvider.start(); + + 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())); + } + } }