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;
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;
23 import java.util.ArrayList;
24 import java.util.List;
27 public class LatestEntryRoutingLogicTest {
29 static ActorSystem system;
32 public static void setup() throws InterruptedException {
33 system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster"));
37 public static void teardown() {
38 JavaTestKit.shutdownActorSystem(system);
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));