@Test
  public void testOveralyOnOtherCluster() throws Exception {
    // just run HDFS
    HBaseTestingUtil util1 = new HBaseTestingUtil();
    MiniDFSCluster dfs = util1.startMiniDFSCluster(1);

    // run HBase on that HDFS
    HBaseTestingUtil util2 = new HBaseTestingUtil();
    // set the dfs
    util2.setDFSCluster(dfs, false);
    util2.startMiniCluster();

    // ensure that they are pointed at the same place
    FileSystem fs = dfs.getFileSystem();
    FileSystem targetFs = util2.getDFSCluster().getFileSystem();
    assertFsSameUri(fs, targetFs);

    fs = FileSystem.get(util1.getConfiguration());
    targetFs = FileSystem.get(util2.getConfiguration());
    assertFsSameUri(fs, targetFs);

    Path randomFile = new Path("/" + util1.getRandomUUID());
    assertTrue(targetFs.createNewFile(randomFile));
    assertTrue(fs.exists(randomFile));

    // do a simple create/write to ensure the cluster works as expected
    byte[] family = Bytes.toBytes("testfamily");
    final TableName tablename = TableName.valueOf(name.getMethodName());
    Table table = util2.createTable(tablename, family);
    Put p = new Put(new byte[] { 1, 2, 3 });
    p.addColumn(family, null, new byte[] { 1 });
    table.put(p);

    // shutdown and make sure cleanly shutting down
    util2.shutdownMiniCluster();
    util1.shutdownMiniDFSCluster();
  }
Test that an HBase cluster can run on top of an existing MiniDfsCluster
hbase-server/src/test/java/org/apache/hadoop/hbase/TestHBaseOnOtherDfsCluster.java