Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / OpsListenerTest.java
1 /*
2  * Copyright (c) 2014, 2017 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 package org.opendaylight.controller.remote.rpc;
9
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;
26
27 public class OpsListenerTest {
28
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);
35
36     private static ActorSystem SYSTEM;
37
38     @BeforeClass
39     public static void setup() {
40         SYSTEM = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
41     }
42
43     @AfterClass
44     public static void teardown() {
45         TestKit.shutdownActorSystem(SYSTEM);
46         SYSTEM = null;
47     }
48
49     @Test
50     public void testRouteAdd() {
51         // Test announcements
52         final TestKit probeReg = new TestKit(SYSTEM);
53         final ActorRef rpcRegistry = probeReg.getRef();
54
55         final OpsListener opsListener = new OpsListener(rpcRegistry, rpcRegistry);
56         opsListener.onRpcAvailable(Collections.singleton(RPC_ID));
57         probeReg.expectMsgClass(RpcRegistry.Messages.AddOrUpdateRoutes.class);
58     }
59
60     @Test
61     public void testActionRouteAdd() {
62         // Test announcements
63         final TestKit probeReg = new TestKit(SYSTEM);
64         final ActorRef actionRegistry = probeReg.getRef();
65
66         final OpsListener opsListener = new OpsListener(actionRegistry, actionRegistry);
67         opsListener.onActionsChanged(Collections.emptySet(),Collections.singleton(ACTION_INSTANCE));
68         probeReg.expectMsgClass(ActionRegistry.Messages.UpdateActions.class);
69     }
70
71     @Test
72     public void testRouteRemove() {
73         // Test announcements
74         final TestKit probeReg = new TestKit(SYSTEM);
75         final ActorRef rpcRegistry = probeReg.getRef();
76
77         final OpsListener opsListener = new OpsListener(rpcRegistry, rpcRegistry);
78         opsListener.onRpcUnavailable(Collections.singleton(RPC_ID));
79         probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class);
80     }
81
82 //    @Test
83 //    public void testAcceptsImplementation() {
84 //
85 //        final TestKit probeReg = new TestKit(SYSTEM);
86 //        final ActorRef opsRegistry = probeReg.getRef();
87 //
88 //        final OpsListener opsListener = new OpsListener(opsRegistry, opsRegistry);
89 //        opsListener.acceptsImplementation()
90 //    }
91 }