@Test() public void testController() throws Exception { System.out.println( "START " + className + ".testController() at " + new Date(System.currentTimeMillis())); final String clusterName = CLUSTER_PREFIX + "_" + className + "_controller"; // basic test if (_gZkClient.exists("/" + clusterName)) { _gZkClient.deleteRecursive("/" + clusterName); } ZKHelixManager controller = new ZKHelixManager(clusterName, null, InstanceType.CONTROLLER, ZK_ADDR); try { controller.connect(); Assert.fail("Should throw HelixException if initial cluster structure is not setup"); } catch (HelixException e) { // OK } TestHelper.setupEmptyCluster(_gZkClient, clusterName); controller.connect(); AssertJUnit.assertTrue(controller.isConnected()); controller.connect(); AssertJUnit.assertTrue(controller.isConnected()); MockListener listener = new MockListener(); listener.reset(); try { controller.addControllerListener(null); Assert.fail("Should throw HelixException"); } catch (HelixException e) { // OK } Builder keyBuilder = new Builder(controller.getClusterName()); controller.addControllerListener(listener); AssertJUnit.assertTrue(listener.isControllerChangeListenerInvoked); controller.removeListener(keyBuilder.controller(), listener); ZkHelixPropertyStore<ZNRecord> store = controller.getHelixPropertyStore(); ZNRecord record = new ZNRecord("node_1"); int options = 0; store.set("/node_1", record, AccessOption.PERSISTENT); Stat stat = new Stat(); record = store.get("/node_1", stat, options); AssertJUnit.assertEquals("node_1", record.getId()); controller.getMessagingService(); controller.getHealthReportCollector(); controller.getClusterManagmentTool(); controller.handleNewSession(); controller.disconnect(); AssertJUnit.assertFalse(controller.isConnected()); System.out.println( "END " + className + ".testController() at " + new Date(System.currentTimeMillis())); }