Merge "Bug 1637: Change Rpc actor calls to async"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / utils / TestUtils.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.cluster.datastore.utils;
10
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSystem;
13 import akka.actor.Props;
14 import junit.framework.Assert;
15
16 import java.util.List;
17
18 public class TestUtils {
19
20     public static void assertFirstSentMessage(ActorSystem actorSystem, ActorRef actorRef, Class clazz){
21         ActorContext testContext = new ActorContext(actorSystem, actorSystem.actorOf(
22             Props.create(DoNothingActor.class)), new MockClusterWrapper(), new MockConfiguration());
23         Object messages = testContext
24             .executeLocalOperation(actorRef, "messages");
25
26         Assert.assertNotNull(messages);
27
28         Assert.assertTrue(messages instanceof List);
29
30         List<Object> listMessages = (List<Object>) messages;
31
32         Assert.assertEquals(1, listMessages.size());
33
34         Assert.assertTrue(listMessages.get(0).getClass().equals(clazz));
35     }
36 }