Merge "Bug 1536: Fixed minimum values of SET_TP_SRC/DST."
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / RemoteRpcProviderTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9
10 package org.opendaylight.controller.remote.rpc;
11
12
13 import akka.actor.ActorRef;
14 import akka.actor.ActorSystem;
15 import akka.testkit.JavaTestKit;
16 import com.typesafe.config.ConfigFactory;
17 import junit.framework.Assert;
18 import org.junit.AfterClass;
19 import org.junit.BeforeClass;
20 import org.junit.Test;
21 import org.opendaylight.controller.sal.core.api.Broker;
22 import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
23 import org.opendaylight.controller.sal.core.api.model.SchemaService;
24 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
25 import scala.concurrent.Await;
26 import scala.concurrent.duration.Duration;
27
28
29 import java.util.concurrent.TimeUnit;
30
31 import static org.mockito.Mockito.mock;
32 import static org.mockito.Mockito.when;
33
34 public class RemoteRpcProviderTest {
35
36   static ActorSystem system;
37
38
39   @BeforeClass
40   public static void setup() throws InterruptedException {
41     system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster"));
42   }
43
44   @AfterClass
45   public static void teardown() {
46     JavaTestKit.shutdownActorSystem(system);
47     system = null;
48   }
49
50   @Test
51   public void testRemoteRpcProvider() throws Exception {
52     RemoteRpcProvider rpcProvider = new RemoteRpcProvider(system, mock(RpcProvisionRegistry.class));
53     Broker.ProviderSession session = mock(Broker.ProviderSession.class);
54     SchemaService schemaService = mock(SchemaService.class);
55     when(schemaService.getGlobalContext()). thenReturn(mock(SchemaContext.class));
56     when(session.getService(SchemaService.class)).thenReturn(schemaService);
57     rpcProvider.onSessionInitiated(session);
58     ActorRef actorRef = Await.result(system.actorSelection(ActorConstants.RPC_MANAGER_PATH).resolveOne(Duration.create(1, TimeUnit.SECONDS)),
59         Duration.create(2, TimeUnit.SECONDS));
60     Assert.assertTrue(actorRef.path().toString().contains(ActorConstants.RPC_MANAGER_PATH));
61   }
62
63
64
65 }