Bug 7521: Move DatastoreSnapshotList et al to persisted package
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / shardmanager / ShardManagerGetSnapshotReplyActorTest.java
index beabd5e3f8a218271a7beb01d6206153c761044d..f2b11b01c311aaaf0b798ed809fed267dd9f3d75 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.cluster.datastore.shardmanager;
 
 import static org.junit.Assert.assertArrayEquals;
 import static org.junit.Assert.assertEquals;
+
 import akka.actor.ActorRef;
 import akka.actor.Status.Failure;
 import akka.actor.Terminated;
@@ -17,14 +18,12 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-import org.junit.After;
 import org.junit.Test;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.datastore.AbstractActorTest;
 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
-import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot.ShardSnapshot;
-import org.opendaylight.controller.cluster.raft.TestActorFactory;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot;
+import org.opendaylight.controller.cluster.datastore.persisted.DatastoreSnapshot.ShardSnapshot;
 import org.opendaylight.controller.cluster.raft.client.messages.GetSnapshotReply;
 import scala.concurrent.duration.Duration;
 import scala.concurrent.duration.FiniteDuration;
@@ -37,38 +36,30 @@ import scala.concurrent.duration.FiniteDuration;
 public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
     private static final MemberName MEMBER_1 = MemberName.forName("member-1");
 
-    private final TestActorFactory actorFactory = new TestActorFactory(getSystem());
-
-    @After
-    public void tearDown() {
-        actorFactory.close();
-    }
-
     @Test
     public void testSuccess() {
         JavaTestKit kit = new JavaTestKit(getSystem());
 
         byte[] shardManagerSnapshot = new byte[]{0,5,9};
-        ActorRef replyActor = actorFactory.createActor(ShardManagerGetSnapshotReplyActor.props(
-                Arrays.asList("shard1", "shard2", "shard3"), "config",
-                shardManagerSnapshot, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.SECONDS)),
-                    actorFactory.generateActorId("actor"));
+        ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
+                Arrays.asList("shard1", "shard2", "shard3"), "config", shardManagerSnapshot, kit.getRef(),
+                "shard-manager", Duration.create(100, TimeUnit.SECONDS)), "testSuccess");
 
         kit.watch(replyActor);
 
         byte[] shard1Snapshot = new byte[]{1,2,3};
-        replyActor.tell(new GetSnapshotReply(ShardIdentifier.builder().memberName(MEMBER_1).type("config").
-                shardName("shard1").build().toString(), shard1Snapshot), ActorRef.noSender());
+        replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(),
+            shard1Snapshot), ActorRef.noSender());
 
         byte[] shard2Snapshot = new byte[]{4,5,6};
-        replyActor.tell(new GetSnapshotReply(ShardIdentifier.builder().memberName(MEMBER_1).type("config").
-                shardName("shard2").build().toString(), shard2Snapshot), ActorRef.noSender());
+        replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard2", MEMBER_1, "config").toString(),
+            shard2Snapshot), ActorRef.noSender());
 
         kit.expectNoMsg(FiniteDuration.create(500, TimeUnit.MILLISECONDS));
 
         byte[] shard3Snapshot = new byte[]{7,8,9};
-        replyActor.tell(new GetSnapshotReply(ShardIdentifier.builder().memberName(MEMBER_1).type("config").
-                shardName("shard3").build().toString(), shard3Snapshot), ActorRef.noSender());
+        replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard3", MEMBER_1, "config").toString(),
+            shard3Snapshot), ActorRef.noSender());
 
         DatastoreSnapshot datastoreSnapshot = kit.expectMsgClass(DatastoreSnapshot.class);
 
@@ -91,15 +82,14 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
         JavaTestKit kit = new JavaTestKit(getSystem());
 
         byte[] shardManagerSnapshot = new byte[]{0,5,9};
-        ActorRef replyActor = actorFactory.createActor(ShardManagerGetSnapshotReplyActor.props(
-                Arrays.asList("shard1", "shard2"), "config",
-                shardManagerSnapshot, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.SECONDS)),
-                    actorFactory.generateActorId("actor"));
+        ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
+                Arrays.asList("shard1", "shard2"), "config", shardManagerSnapshot, kit.getRef(), "shard-manager",
+                Duration.create(100, TimeUnit.SECONDS)), "testGetSnapshotFailureReply");
 
         kit.watch(replyActor);
 
-        replyActor.tell(new GetSnapshotReply(ShardIdentifier.builder().memberName(MEMBER_1).type("config").
-                shardName("shard1").build().toString(), new byte[]{1,2,3}), ActorRef.noSender());
+        replyActor.tell(new GetSnapshotReply(ShardIdentifier.create("shard1", MEMBER_1, "config").toString(),
+            new byte[]{1,2,3}), ActorRef.noSender());
 
         replyActor.tell(new Failure(new RuntimeException()), ActorRef.noSender());
 
@@ -112,10 +102,9 @@ public class ShardManagerGetSnapshotReplyActorTest extends AbstractActorTest {
         JavaTestKit kit = new JavaTestKit(getSystem());
 
         byte[] shardManagerSnapshot = new byte[]{0,5,9};
-        ActorRef replyActor = actorFactory.createActor(ShardManagerGetSnapshotReplyActor.props(
-                Arrays.asList("shard1"), "config",
-                shardManagerSnapshot, kit.getRef(), "shard-manager", Duration.create(100, TimeUnit.MILLISECONDS)),
-                    actorFactory.generateActorId("actor"));
+        ActorRef replyActor = getSystem().actorOf(ShardManagerGetSnapshotReplyActor.props(
+                Arrays.asList("shard1"), "config", shardManagerSnapshot, kit.getRef(), "shard-manager",
+                Duration.create(100, TimeUnit.MILLISECONDS)), "testGetSnapshotTimeout");
 
         kit.watch(replyActor);