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=c84197cf6abb462f859750d9e6031ed38c51ae45;hb=a4fcc7debbd036c6e1df8c88df1c0268c62e76e4;hp=e1f93f8b390b6e9a3f12d773553ec8296100e13f;hpb=2fb20e0091de8945147ca984721b23d28161aa8d;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 e1f93f8b39..c84197cf6a 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,65 +1,55 @@ /* - * 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 static org.mockito.Mockito.when; import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; 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.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 org.opendaylight.mdsal.dom.api.DOMRpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMRpcService; import scala.concurrent.Await; import scala.concurrent.duration.Duration; public class RemoteRpcProviderTest { + static ActorSystem system; + static RemoteRpcProviderConfig moduleConfig; - 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); + @BeforeClass + public static void setup() { + 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; - } + @AfterClass + public static void teardown() { + TestKit.shutdownActorSystem(system); + system = null; + } @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)); + try (RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(DOMRpcProviderService.class), + mock(DOMRpcService.class), new RemoteRpcProviderConfig(system.settings().config()))) { - rpcProvider.onSessionInitiated(session); + rpcProvider.start(); final ActorRef actorRef = Await.result( system.actorSelection(moduleConfig.getRpcManagerPath()).resolveOne(