2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.controller.remote.rpc;
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;
22 import java.net.URISyntaxException;
24 public class RpcListenerTest {
26 static ActorSystem system;
30 public static void setup() throws InterruptedException {
31 system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
35 public static void teardown() {
36 JavaTestKit.shutdownActorSystem(system);
41 public void testRpcAdd() throws URISyntaxException {
42 new JavaTestKit(system) {
44 JavaTestKit probeReg = new JavaTestKit(system);
45 ActorRef rpcRegistry = probeReg.getRef();
47 RpcListener rpcListener = new RpcListener(rpcRegistry);
49 QName qName = new QName(new URI("actor2"), "actor2");
51 rpcListener.onRpcImplementationAdded(qName);
52 probeReg.expectMsgClass(RpcRegistry.Messages.AddOrUpdateRoutes.class);
58 public void testRpcRemove() throws URISyntaxException {
59 new JavaTestKit(system) {
61 JavaTestKit probeReg = new JavaTestKit(system);
62 ActorRef rpcRegistry = probeReg.getRef();
64 RpcListener rpcListener = new RpcListener(rpcRegistry);
66 QName qName = new QName(new URI("actor2"), "actor2");
68 rpcListener.onRpcImplementationRemoved(qName);
69 probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class);