2 * Copyright (c) 2014, 2017 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
8 package org.opendaylight.controller.remote.rpc;
10 import akka.actor.ActorRef;
11 import akka.actor.ActorSystem;
12 import akka.testkit.javadsl.TestKit;
13 import com.typesafe.config.ConfigFactory;
14 import java.util.Collections;
15 import org.junit.AfterClass;
16 import org.junit.BeforeClass;
17 import org.junit.Test;
18 import org.opendaylight.controller.remote.rpc.registry.ActionRegistry;
19 import org.opendaylight.controller.remote.rpc.registry.RpcRegistry;
20 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
21 import org.opendaylight.mdsal.dom.api.DOMActionInstance;
22 import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
23 import org.opendaylight.yangtools.yang.common.QName;
24 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
25 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
27 public class OpsListenerTest {
29 private static final QName TEST_QNAME = QName.create("test", "2015-06-12", "test");
30 private static final Absolute RPC_TYPE = Absolute.of(TEST_QNAME);
31 private static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier.of(TEST_QNAME);
32 private static final DOMRpcIdentifier RPC_ID = DOMRpcIdentifier.create(TEST_QNAME, TEST_PATH);
33 private static final DOMActionInstance ACTION_INSTANCE = DOMActionInstance.of(RPC_TYPE,
34 LogicalDatastoreType.OPERATIONAL, TEST_PATH);
36 private static ActorSystem SYSTEM;
39 public static void setup() {
40 SYSTEM = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
44 public static void teardown() {
45 TestKit.shutdownActorSystem(SYSTEM);
50 public void testRouteAdd() {
52 final TestKit probeReg = new TestKit(SYSTEM);
53 final ActorRef rpcRegistry = probeReg.getRef();
55 final OpsListener opsListener = new OpsListener(rpcRegistry, rpcRegistry);
56 opsListener.onRpcAvailable(Collections.singleton(RPC_ID));
57 probeReg.expectMsgClass(RpcRegistry.Messages.AddOrUpdateRoutes.class);
61 public void testActionRouteAdd() {
63 final TestKit probeReg = new TestKit(SYSTEM);
64 final ActorRef actionRegistry = probeReg.getRef();
66 final OpsListener opsListener = new OpsListener(actionRegistry, actionRegistry);
67 opsListener.onActionsChanged(Collections.emptySet(),Collections.singleton(ACTION_INSTANCE));
68 probeReg.expectMsgClass(ActionRegistry.Messages.UpdateActions.class);
72 public void testRouteRemove() {
74 final TestKit probeReg = new TestKit(SYSTEM);
75 final ActorRef rpcRegistry = probeReg.getRef();
77 final OpsListener opsListener = new OpsListener(rpcRegistry, rpcRegistry);
78 opsListener.onRpcUnavailable(Collections.singleton(RPC_ID));
79 probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class);
83 // public void testAcceptsImplementation() {
85 // final TestKit probeReg = new TestKit(SYSTEM);
86 // final ActorRef opsRegistry = probeReg.getRef();
88 // final OpsListener opsListener = new OpsListener(opsRegistry, opsRegistry);
89 // opsListener.acceptsImplementation()