@Test
  public void createClient() {
    try {
      new HiveMetaStoreClient(conf);
      Assert.fail("an exception is expected");
    } catch (Exception e) {
      Assert.assertTrue(e instanceof MetaException);
      Assert.assertTrue(e.getMessage().contains("No metastore service discovered in ZooKeeper"));
    }
  }
Test MetaStore Client throws exception when no MetaStore spec found in zookeeper.
standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHMSZKNegative.java