### Question:
LocalHBaseCluster { public LocalHBaseCluster(final Configuration conf) throws IOException { this(conf, DEFAULT_NO); } LocalHBaseCluster(final Configuration conf);  LocalHBaseCluster(final Configuration conf, final int noRegionServers);  LocalHBaseCluster(final Configuration conf, final int noMasters,
      final int noRegionServers); @SuppressWarnings("unchecked")  LocalHBaseCluster(final Configuration conf, final int noMasters,
    final int noRegionServers, final Class<? extends HMaster> masterClass,
    final Class<? extends HRegionServer> regionServerClass); JVMClusterUtil.RegionServerThread addRegionServer(); JVMClusterUtil.RegionServerThread addRegionServer(
      Configuration config, final int index); JVMClusterUtil.RegionServerThread addRegionServer(
      final Configuration config, final int index, User user); JVMClusterUtil.MasterThread addMaster(); JVMClusterUtil.MasterThread addMaster(Configuration c, final int index); JVMClusterUtil.MasterThread addMaster(
      final Configuration c, final int index, User user); HRegionServer getRegionServer(int serverNumber); List<JVMClusterUtil.RegionServerThread> getRegionServers(); List<JVMClusterUtil.RegionServerThread> getLiveRegionServers(); String waitOnRegionServer(int serverNumber); String waitOnRegionServer(JVMClusterUtil.RegionServerThread rst); HMaster getMaster(int serverNumber); HMaster getActiveMaster(); List<JVMClusterUtil.MasterThread> getMasters(); List<JVMClusterUtil.MasterThread> getLiveMasters(); String waitOnMaster(int serverNumber); String waitOnMaster(JVMClusterUtil.MasterThread masterThread); void join(); void startup(); void shutdown(); static boolean isLocal(final Configuration c); static void main(String[] args); static final String LOCAL; static final String LOCAL_COLON; }### Answer:
@Test public void testLocalHBaseCluster() throws Exception { Configuration conf = TEST_UTIL.getConfiguration(); conf.set(HConstants.HBASE_DIR, TEST_UTIL.getDataTestDir("hbase.rootdir"). makeQualified(TEST_UTIL.getTestFileSystem().getUri(), TEST_UTIL.getTestFileSystem().getWorkingDirectory()).toString()); MiniZooKeeperCluster zkCluster = TEST_UTIL.startMiniZKCluster(); conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, Integer.toString(zkCluster.getClientPort())); LocalHBaseCluster cluster = new LocalHBaseCluster(conf, 1, 1, MyHMaster.class, MyHRegionServer.class); try { ((MyHMaster)cluster.getMaster(0)).setZKCluster(zkCluster); } catch (ClassCastException e) { fail("Could not cast master to our class"); } try { ((MyHRegionServer)cluster.getRegionServer(0)).echo(42); } catch (ClassCastException e) { fail("Could not cast regionserver to our class"); } try { cluster.startup(); waitForClusterUp(conf); } catch (IOException e) { fail("LocalHBaseCluster did not start successfully"); } finally { cluster.shutdown(); } }
@Test public void testLocalHBaseCluster() throws Exception { TEST_UTIL.startMiniCluster(1, 1, null, MyHMaster.class, MyHRegionServer.class); try { int val = ((MyHMaster)TEST_UTIL.getHBaseCluster().getMaster(0)).echo(42); assertEquals(42, val); } catch (ClassCastException e) { fail("Could not cast master to our class"); } try { int val = ((MyHRegionServer)TEST_UTIL.getHBaseCluster().getRegionServer(0)).echo(42); assertEquals(42, val); } catch (ClassCastException e) { fail("Could not cast regionserver to our class"); } TEST_UTIL.shutdownMiniCluster(); }