Migrate from JavaTestKit to javadsl.TestKit
[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 import static org.junit.Assert.assertTrue;
12
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;
24
25 public class LatestEntryRoutingLogicTest {
26     static ActorSystem system;
27
28     @BeforeClass
29     public static void setup() throws InterruptedException {
30         system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
31     }
32
33     @AfterClass
34     public static void teardown() {
35         TestKit.shutdownActorSystem(system);
36         system = null;
37     }
38
39     @Test
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));
53     }
54 }