String controllerName = "controller_0";
MockController controller = new MockController(_zkaddr, clusterName, controllerName);
GenericHelixController pipeline = new GenericHelixController();
ZkHelixLeaderElection leader = new ZkHelixLeaderElection(controller.getController(), pipeline);
NotificationContext context = new NotificationContext(controller);
context.setType(NotificationContext.Type.INIT);
leader.onControllerChange(context);
LiveInstance liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
// Start another controller, leader should remain unchanged
String controllerName1 = "controller_1";
MockController controller1 = new MockController(_zkaddr, clusterName, controllerName1);
GenericHelixController pipeline1 = new GenericHelixController();
ZkHelixLeaderElection leader1 = new ZkHelixLeaderElection(controller1.getController(), pipeline1);
NotificationContext context1 = new NotificationContext(controller1);
context1.setType(NotificationContext.Type.INIT);
leader1.onControllerChange(context1);
liveInstance = accessor.getProperty(keyBuilder.controllerLeader());
AssertJUnit.assertEquals(controllerName, liveInstance.getInstanceName());
// clean up
controller1.getConn().disconnect();