X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-remoterpc-connector%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fremote%2Frpc%2FRpcListenerTest.java;h=37d81c7afb7859e9e18b616afdef46befad71f42;hb=f09d37ec4cce2411eaae11dde18f9ce2d2f14118;hp=7b5a968866ca1ecca306b42fc09d76b0a6aaf20a;hpb=9228eee6e438894b091f7bee8a4ba7b53286ef8f;p=controller.git 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 7b5a968866..37d81c7afb 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 @@ -8,66 +8,70 @@ package org.opendaylight.controller.remote.rpc; + import akka.actor.ActorRef; import akka.actor.ActorSystem; import akka.testkit.JavaTestKit; import com.typesafe.config.ConfigFactory; +import java.net.URISyntaxException; +import java.util.Collections; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.opendaylight.controller.md.sal.dom.api.DOMRpcIdentifier; import org.opendaylight.controller.remote.rpc.registry.RpcRegistry; 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")); - } - - @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); - probeReg.expectMsgClass(RpcRegistry.Messages.AddOrUpdateRoutes.class); - }}; - - } - - @Test - public void testRpcRemove() 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.onRpcImplementationRemoved(qName); - probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class); - }}; - - } + 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); + 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 testRouteAdd() throws URISyntaxException, InterruptedException { + new JavaTestKit(system) { + { + // Test announcements + final JavaTestKit probeReg = new JavaTestKit(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 testRouteRemove() throws URISyntaxException, InterruptedException { + new JavaTestKit(system) { + { + // Test announcements + final JavaTestKit probeReg = new JavaTestKit(system); + final ActorRef rpcRegistry = probeReg.getRef(); + + final RpcListener rpcListener = new RpcListener(rpcRegistry); + rpcListener.onRpcUnavailable(Collections.singleton(RPC_ID)); + probeReg.expectMsgClass(RpcRegistry.Messages.RemoveRoutes.class); + } + }; + } }