cd031a1d0abcf330b3c63c90a576b65dc2cd2d1d
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / test / java / org / opendaylight / controller / remote / rpc / utils / LatestEntryRoutingLogicTest.java
1 /*
2  * Copyright (c) 2014 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
9 package org.opendaylight.controller.remote.rpc.utils;
10
11
12 import akka.actor.ActorRef;
13 import akka.actor.ActorSystem;
14 import akka.japi.Pair;
15 import akka.testkit.JavaTestKit;
16 import akka.testkit.TestProbe;
17 import com.typesafe.config.ConfigFactory;
18 import junit.framework.Assert;
19 import org.junit.AfterClass;
20 import org.junit.BeforeClass;
21 import org.junit.Test;
22
23 import java.util.ArrayList;
24 import java.util.List;
25
26
27 public class LatestEntryRoutingLogicTest {
28
29   static ActorSystem system;
30
31   @BeforeClass
32   public static void setup() throws InterruptedException {
33     system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
34   }
35
36   @AfterClass
37   public static void teardown() {
38     JavaTestKit.shutdownActorSystem(system);
39     system = null;
40   }
41
42   @Test
43   public void testRoutingLogic() {
44     List<Pair<ActorRef, Long>> pairList = new ArrayList<>();
45     TestProbe probe1 = new TestProbe(system);
46     TestProbe probe2 = new TestProbe(system);
47     TestProbe probe3 = new TestProbe(system);
48     ActorRef actor1 = probe1.ref();
49     ActorRef actor2 = probe2.ref();
50     ActorRef actor3 = probe3.ref();
51     pairList.add(new Pair<ActorRef, Long>(actor1, 1000L));
52     pairList.add(new Pair<ActorRef, Long>(actor2, 3000L));
53     pairList.add(new Pair<ActorRef, Long>(actor3, 2000L));
54     RoutingLogic logic = new LatestEntryRoutingLogic(pairList);
55     Assert.assertTrue(logic.select().equals(actor2));
56   }
57 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.