@Before
  public void before() throws Exception {
    SessionState.start(hiveConf);
    try {
      hm = Hive.get(hiveConf);
    } catch (Exception e) {
      System.err.println(StringUtils.stringifyException(e));
      System.err
          .println("Unable to initialize Hive Metastore using configuration: \n "
          + hiveConf);
      throw e;
    }
  }
Start a remote metastore and initialize a Hive object pointing at it.
ql/src/test/org/apache/hadoop/hive/ql/metadata/TestHiveRemote.java