X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRpcListenerTest.java;h=7ae8a0a57fdf9fc963522beb03d34a6ad482cd6a;hp=956e1599904ccc52303ff380892bc3531861cd5b;hb=a2b838f96589b502578fa4e15cef2769f886a378;hpb=287b1d1ecec3264c192b1007019bfcadf6cb4311 diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java index 956e159990..7ae8a0a57f 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java +++ b/opendaylight/md-sal/sal-remoterpc-connector/src/test/java/org/opendaylight/controller/remote/rpc/RpcListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2014, 2017 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -10,64 +10,58 @@ package org.opendaylight.controller.remote.rpc; import akka.actor.ActorRef; import akka.actor.ActorSystem; -import akka.testkit.JavaTestKit; +import akka.testkit.javadsl.TestKit; import com.typesafe.config.ConfigFactory; +import java.util.Collections; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; +import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier; import org.opendaylight.yangtools.yang.common.QName; - -import java.net.URI; -import java.net.URISyntaxException; +import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; +import org.opendaylight.yangtools.yang.model.api.SchemaPath; public class RpcListenerTest { - static ActorSystem system; - - - @BeforeClass - public static void setup() throws InterruptedException { - system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc")); - } - - @AfterClass - public static void teardown() { - JavaTestKit.shutdownActorSystem(system); - system = null; - } - - @Test - public void testRpcAdd() throws URISyntaxException { - new JavaTestKit(system) { - { - JavaTestKit probeReg = new JavaTestKit(system); - ActorRef rpcRegistry = probeReg.getRef(); - - RpcListener rpcListener = new RpcListener(rpcRegistry); - - QName qName = new QName(new URI("actor2"), "actor2"); - - rpcListener.onRpcImplementationAdded(qName); + private static final QName TEST_QNAME = QName.create("test", "2015-06-12", "test"); + private static final SchemaPath RPC_TYPE = SchemaPath.create(true, TEST_QNAME); + private static final YangInstanceIdentifier TEST_PATH = YangInstanceIdentifier + .create(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)); + private static final DOMRpcIdentifier RPC_ID = DOMRpcIdentifier.create(RPC_TYPE, TEST_PATH); + + private static ActorSystem SYSTEM; + + @BeforeClass + public static void setup() { + SYSTEM = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc")); + } + + @AfterClass + public static void teardown() { + TestKit.shutdownActorSystem(SYSTEM); + SYSTEM = null; + } + + @Test + public void testRouteAdd() { + // Test announcements + final TestKit probeReg = new TestKit(SYSTEM); + final ActorRef rpcRegistry = probeReg.getRef(); + + final RpcListener rpcListener = new RpcListener(rpcRegistry); + rpcListener.onRpcAvailable(Collections.singleton(RPC_ID)); probeReg.expectMsgClass(RpcRegistry.Messages.AddOrUpdateRoutes.class); - }}; - - } + } - @Test - public void testRpcRemove() throws URISyntaxException { - new JavaTestKit(system) { - { - JavaTestKit probeReg = new JavaTestKit(system); - ActorRef rpcRegistry = probeReg.getRef(); + @Test + public void testRouteRemove() { + // Test announcements + final TestKit probeReg = new TestKit(SYSTEM); + final ActorRef rpcRegistry = probeReg.getRef(); - RpcListener rpcListener = new RpcListener(rpcRegistry); - - QName qName = new QName(new URI("actor2"), "actor2"); - - rpcListener.onRpcImplementationRemoved(qName); + final RpcListener rpcListener = new RpcListener(rpcRegistry); + rpcListener.onRpcUnavailable(Collections.singleton(RPC_ID)); probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class); - }}; - - } + } }