import akka.actor.UntypedActor;
import akka.dispatch.Futures;
import akka.japi.Creator;
-import akka.testkit.JavaTestKit;
import akka.testkit.TestActorRef;
+import akka.testkit.javadsl.TestKit;
import akka.util.Timeout;
import com.google.common.base.Optional;
import com.google.common.collect.Maps;
import org.opendaylight.controller.cluster.datastore.messages.RemotePrimaryShardFound;
import org.opendaylight.controller.cluster.raft.utils.EchoActor;
import org.opendaylight.controller.cluster.raft.utils.MessageCollectorActor;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static class TestMessage {
}
- private static class MockShardManager extends UntypedActor {
+ private static final class MockShardManager extends UntypedActor {
private final boolean found;
private final ActorRef actorRef;
@Test
public void testFindLocalShardWithShardFound() {
- new JavaTestKit(getSystem()) {
+ new TestKit(getSystem()) {
{
- new Within(duration("1 seconds")) {
- @Override
- protected void run() {
+ within(duration("1 seconds"), () -> {
+ ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
- ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
+ ActorRef shardManagerActorRef = getSystem()
+ .actorOf(MockShardManager.props(true, shardActorRef));
- ActorRef shardManagerActorRef = getSystem()
- .actorOf(MockShardManager.props(true, shardActorRef));
-
- ActorContext actorContext = new ActorContext(getSystem(), shardManagerActorRef,
- mock(ClusterWrapper.class), mock(Configuration.class));
+ ActorContext actorContext = new ActorContext(getSystem(), shardManagerActorRef,
+ mock(ClusterWrapper.class), mock(Configuration.class));
- Optional<ActorRef> out = actorContext.findLocalShard("default");
+ Optional<ActorRef> out = actorContext.findLocalShard("default");
- assertEquals(shardActorRef, out.get());
+ assertEquals(shardActorRef, out.get());
- expectNoMsg();
- }
- };
+ expectNoMsg();
+ return null;
+ });
}
};
@Test
public void testFindLocalShardWithShardNotFound() {
- new JavaTestKit(getSystem()) {
+ new TestKit(getSystem()) {
{
ActorRef shardManagerActorRef = getSystem().actorOf(MockShardManager.props(false, null));
@Test
public void testExecuteRemoteOperation() {
- new JavaTestKit(getSystem()) {
+ new TestKit(getSystem()) {
{
ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
@Test
@SuppressWarnings("checkstyle:IllegalCatch")
public void testExecuteRemoteOperationAsync() {
- new JavaTestKit(getSystem()) {
+ new TestKit(getSystem()) {
{
ActorRef shardActorRef = getSystem().actorOf(Props.create(EchoActor.class));
@Test
public void testSetDatastoreContext() {
- new JavaTestKit(getSystem()) {
+ new TestKit(getSystem()) {
{
ActorContext actorContext = new ActorContext(getSystem(), getRef(),
mock(ClusterWrapper.class), mock(Configuration.class), DatastoreContext.newBuilder()
@Test
public void testBroadcast() {
- new JavaTestKit(getSystem()) {
+ new TestKit(getSystem()) {
{
ActorRef shardActorRef1 = getSystem().actorOf(MessageCollectorActor.props());
ActorRef shardActorRef2 = getSystem().actorOf(MessageCollectorActor.props());