HBaseBootstrap implements BootstrapHadoop { @Override public org.apache.hadoop.conf.Configuration getConfiguration() { return hbaseLocalCluster.getHbaseConfiguration(); } HBaseBootstrap();  HBaseBootstrap(URL url); @Override ComponentMetadata getMetadata(); @Override String getProperties(); @Override void loadConfig(Map<String, String> configs); @Override Bootstrap start(); @Override Bootstrap stop(); @Override org.apache.hadoop.conf.Configuration getConfiguration();  }
@Test public void hBaseShouldStart() throws Exception { String tableName = configuration.getString(HBaseConfig.HBASE_TEST_TABLE_NAME_KEY); String colFamName = configuration.getString(HBaseConfig.HBASE_TEST_COL_FAMILY_NAME_KEY); String colQualiferName = configuration.getString(HBaseConfig.HBASE_TEST_COL_QUALIFIER_NAME_KEY); Integer numRowsToPut = configuration.getInt(HBaseConfig.HBASE_TEST_NUM_ROWS_TO_PUT_KEY); org.apache.hadoop.conf.Configuration hbaseConfiguration = ((BootstrapHadoop) HadoopBootstrap.INSTANCE.getService("HBASE")).getConfiguration(); LOGGER.info("HBASE: Deleting table {}", tableName); deleteHbaseTable(tableName, hbaseConfiguration); LOGGER.info("HBASE: Creating table {} with column family {}", tableName, colFamName); createHbaseTable(tableName, colFamName, hbaseConfiguration); LOGGER.info("HBASE: Populate the table with {} rows.", numRowsToPut); for (int i = 0; i < numRowsToPut; i++) { putRow(tableName, colFamName, String.valueOf(i), colQualiferName, "row_" + i, hbaseConfiguration); } LOGGER.info("HBASE: Fetching and comparing the results"); for (int i = 0; i < numRowsToPut; i++) { Result result = getRow(tableName, colFamName, String.valueOf(i), colQualiferName, hbaseConfiguration); assertEquals("row_" + i, new String(result.value())); } }
@Test public void testHbaseRestLocalClusterWithSchemaRequest() throws Exception { String tableName = configuration.getString(HBaseConfig.HBASE_TEST_TABLE_NAME_KEY); String colFamName = configuration.getString(HBaseConfig.HBASE_TEST_COL_FAMILY_NAME_KEY); String colQualiferName = configuration.getString(HBaseConfig.HBASE_TEST_COL_QUALIFIER_NAME_KEY); Integer numRowsToPut = configuration.getInt(HBaseConfig.HBASE_TEST_NUM_ROWS_TO_PUT_KEY); org.apache.hadoop.conf.Configuration hbaseConfiguration = ((BootstrapHadoop) HadoopBootstrap.INSTANCE.getService("HBASE")).getConfiguration(); LOGGER.info("HBASE: Deleting table {}", tableName); deleteHbaseTable(tableName, hbaseConfiguration); LOGGER.info("HBASE: Creating table {} with column family {}", tableName, colFamName); createHbaseTable(tableName, colFamName, hbaseConfiguration); LOGGER.info("HBASE: Populate the table with {} rows.", numRowsToPut); for (int i = 0; i < numRowsToPut; i++) { putRow(tableName, colFamName, String.valueOf(i), colQualiferName, "row_" + i, hbaseConfiguration); } URL url = new URL(String.format("http: configuration.getInt(HBaseConfig.HBASE_REST_PORT_KEY))); URLConnection connection = url.openConnection(); connection.setRequestProperty("Accept-Charset", "UTF-8"); try (BufferedReader response = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { String line = response.readLine(); assertTrue(line.contains(tableName)); } url = new URL(String.format("http: configuration.getInt(HBaseConfig.HBASE_REST_PORT_KEY), tableName)); connection = url.openConnection(); connection.setRequestProperty("Accept-Charset", "UTF-8"); try (BufferedReader response = new BufferedReader(new InputStreamReader(connection.getInputStream()))) { String line = response.readLine(); assertTrue(line.contains("{ NAME=> 'hbase_test_table', IS_META => 'false', COLUMNS => [ { NAME => 'cf1', BLOOMFILTER => 'ROW'")); } }