}
MockHAPartition partition = new MockHAPartition(nodes[2]);
partition.setCurrentViewClusterNodes(allNodes);
DistributedReplicantManagerImpl drm = new DistributedReplicantManagerImpl(partition);
drm.createService();
drm.startService();
CachingListener listener = new CachingListener();
drm.registerListener("TEST", listener);
SecureRandom random = new SecureRandom();
boolean[] added = new boolean[nodes.length];
List lookup = null;
List<ClusterNode> lookupReplicantsNodes = null;
for (int i = 0; i < 10; i++)
{
int node = random.nextInt(nodes.length);
if (added[node])
{
if (node == 2)
drm.remove("TEST");
else
drm._remove("TEST", nodes[node].getName());
added[node] = false;
}
else
{
if (node == 2)
drm.add("TEST", replicants[node]);
else
drm._add("TEST", nodes[node].getName(), replicants[node]);
added[node] = true;
}
// Confirm the proper order of the replicant node names
lookupReplicantsNodes = maskListClass(drm.lookupReplicantsNodes("TEST"));
confirmReplicantList(lookupReplicantsNodes, nodes, added);
// Confirm the proper order of the replicants via lookupReplicants
lookup = maskListClass(drm.lookupReplicants("TEST"));
confirmReplicantList(lookup, replicants, added);
// Confirm the listener got the same list
// assertEquals("Listener received a correct list", lookup,
// maskListClass(listener.replicants));