}
}
@Test(timeout = 7000)
public void testShardManagement() throws Exception {
Node node1 = Mocks.mockNode();
Node node2 = Mocks.mockNode();
Map<String, String> shardMD = new HashMap<String, String>();
shardMD.put("a", "1");
assertEquals(0, _protocol.getShardNodes("shard1").size());
// publish shard
_protocol.publishShard(node1, "shard1");
assertEquals(1, _protocol.getShardNodes("shard1").size());
assertEquals(1, _protocol.getNodeShards(node1.getName()).size());
assertEquals(0, _protocol.getNodeShards(node2.getName()).size());
// publish shard on 2nd node
_protocol.publishShard(node2, "shard1");
assertEquals(2, _protocol.getShardNodes("shard1").size());
assertEquals(1, _protocol.getNodeShards(node1.getName()).size());
assertEquals(1, _protocol.getNodeShards(node2.getName()).size());
// remove shard on first node
_protocol.unpublishShard(node1, "shard1");
assertEquals(1, _protocol.getShardNodes("shard1").size());
assertEquals(0, _protocol.getNodeShards(node1.getName()).size());
assertEquals(1, _protocol.getNodeShards(node2.getName()).size());
// publish 2nd shard
_protocol.publishShard(node1, "shard2");
assertEquals(1, _protocol.getShardNodes("shard1").size());
assertEquals(1, _protocol.getShardNodes("shard2").size());
assertEquals(1, _protocol.getNodeShards(node1.getName()).size());
assertEquals(1, _protocol.getNodeShards(node2.getName()).size());
// remove one shard completely
_protocol.unpublishShard(node1, "shard2");
Map<String, List<String>> shard2NodesMap = _protocol.getShard2NodesMap(Arrays.asList("shard1"));