Update junit Assert imports
[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 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 org.junit.AfterClass;
19 import org.junit.BeforeClass;
20 import org.junit.Test;
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 public class LatestEntryRoutingLogicTest {
26
27   static ActorSystem system;
28
29   @BeforeClass
30   public static void setup() throws InterruptedException {
31     system = ActorSystem.create("opendaylight-rpc", ConfigFactory.load().getConfig("odl-cluster-rpc"));
32   }
33
34   @AfterClass
35   public static void teardown() {
36     JavaTestKit.shutdownActorSystem(system);
37     system = null;
38   }
39
40   @Test
41   public void testRoutingLogic() {
42     List<Pair<ActorRef, Long>> pairList = new ArrayList<>();
43     TestProbe probe1 = new TestProbe(system);
44     TestProbe probe2 = new TestProbe(system);
45     TestProbe probe3 = new TestProbe(system);
46     ActorRef actor1 = probe1.ref();
47     ActorRef actor2 = probe2.ref();
48     ActorRef actor3 = probe3.ref();
49     pairList.add(new Pair<ActorRef, Long>(actor1, 1000L));
50     pairList.add(new Pair<ActorRef, Long>(actor2, 3000L));
51     pairList.add(new Pair<ActorRef, Long>(actor3, 2000L));
52     RoutingLogic logic = new LatestEntryRoutingLogic(pairList);
53     assertTrue(logic.select().equals(actor2));
54   }
55 }