Merge "Bug 1569 - [DEV] Too small variable for OF-Port-Number"
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / RpcListenerTest.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 package org.opendaylight.controller.remote.rpc;
10
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSystem;
13 import akka.testkit.JavaTestKit;
14 import com.typesafe.config.ConfigFactory;
15 import org.junit.AfterClass;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.controller.remote.rpc.registry.RpcRegistry;
19 import org.opendaylight.yangtools.yang.common.QName;
20
21 import java.net.URI;
22 import java.net.URISyntaxException;
23
24 public class RpcListenerTest {
25
26   static ActorSystem system;
27
28
29   @BeforeClass
30   public static void setup() throws InterruptedException {
31     system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
32   }
33
34   @AfterClass
35   public static void teardown() {
36     JavaTestKit.shutdownActorSystem(system);
37     system = null;
38   }
39
40   @Test
41   public void testRpcAdd() throws URISyntaxException {
42     new JavaTestKit(system) {
43       {
44         JavaTestKit probeReg = new JavaTestKit(system);
45         ActorRef rpcRegistry = probeReg.getRef();
46
47         RpcListener rpcListener = new RpcListener(rpcRegistry);
48
49         QName qName = new QName(new URI("actor2"), "actor2");
50
51         rpcListener.onRpcImplementationAdded(qName);
52         probeReg.expectMsgClass(RpcRegistry.Messages.AddOrUpdateRoutes.class);
53       }};
54
55   }
56
57   @Test
58   public void testRpcRemove() throws URISyntaxException {
59     new JavaTestKit(system) {
60       {
61         JavaTestKit probeReg = new JavaTestKit(system);
62         ActorRef rpcRegistry = probeReg.getRef();
63
64         RpcListener rpcListener = new RpcListener(rpcRegistry);
65
66         QName qName = new QName(new URI("actor2"), "actor2");
67
68         rpcListener.onRpcImplementationRemoved(qName);
69         probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class);
70       }};
71
72   }
73 }