+ @Test
+ public void testShardPersistenceWithRestoredData() throws Exception {
+ new JavaTestKit(getSystem()) {{
+ MockConfiguration mockConfig =
+ new MockConfiguration(ImmutableMap.<String, List<String>>builder().
+ put("default", Arrays.asList("member-1", "member-2")).
+ put("astronauts", Arrays.asList("member-2")).
+ put("people", Arrays.asList("member-1", "member-2")).build());
+ String[] restoredShards = {"default", "astronauts"};
+ ShardManagerSnapshot snapshot = new ShardManagerSnapshot(Arrays.asList(restoredShards));
+ InMemorySnapshotStore.addSnapshot(shardMgrID, snapshot);
+
+ //create shardManager to come up with restored data
+ TestActorRef<TestShardManager> newRestoredShardManager = TestActorRef.create(getSystem(),
+ newShardMgrProps(mockConfig));
+
+ newRestoredShardManager.underlyingActor().waitForRecoveryComplete();
+
+ newRestoredShardManager.tell(new FindLocalShard("people", false), getRef());
+ LocalShardNotFound notFound = expectMsgClass(duration("5 seconds"), LocalShardNotFound.class);
+ assertEquals("for uninitialized shard", "people", notFound.getShardName());
+
+ //Verify a local shard is created for the restored shards,
+ //although we expect a NotInitializedException for the shards as the actor initialization
+ //message is not sent for them
+ newRestoredShardManager.tell(new FindLocalShard("default", false), getRef());
+ expectMsgClass(duration("5 seconds"), NotInitializedException.class);
+
+ newRestoredShardManager.tell(new FindLocalShard("astronauts", false), getRef());
+ expectMsgClass(duration("5 seconds"), NotInitializedException.class);
+ }};
+ }
+
+