2 * Copyright (c) 2014 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
9 package org.opendaylight.controller.remote.rpc.utils;
11 import static org.junit.Assert.assertTrue;
13 import akka.actor.ActorRef;
14 import akka.actor.ActorSystem;
15 import akka.japi.Pair;
16 import akka.testkit.TestProbe;
17 import akka.testkit.javadsl.TestKit;
18 import com.typesafe.config.ConfigFactory;
19 import java.util.ArrayList;
20 import java.util.List;
21 import org.junit.AfterClass;
22 import org.junit.BeforeClass;
23 import org.junit.Test;
25 public class LatestEntryRoutingLogicTest {
26 static ActorSystem system;
29 public static void setup() {
30 system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
34 public static void teardown() {
35 TestKit.shutdownActorSystem(system);
40 public void testRoutingLogic() {
41 List<Pair<ActorRef, Long>> pairList = new ArrayList<>();
42 TestProbe probe1 = new TestProbe(system);
43 TestProbe probe2 = new TestProbe(system);
44 TestProbe probe3 = new TestProbe(system);
45 ActorRef actor1 = probe1.ref();
46 ActorRef actor2 = probe2.ref();
47 ActorRef actor3 = probe3.ref();
48 pairList.add(new Pair<>(actor1, 1000L));
49 pairList.add(new Pair<>(actor2, 3000L));
50 pairList.add(new Pair<>(actor3, 2000L));
51 RoutingLogic logic = new LatestEntryRoutingLogic(pairList);
52 assertTrue(logic.select().equals(actor2));