private void setHiveSiteWithRemoteMetastore() throws IOException {
    // new *hive-site.xml file
    String newConfFile = System.getProperty("test.tmp.dir") + File.separator
        + this.getClass().getSimpleName() + "hive-site.xml";

    // create a new conf file, using contents from current one
    // modifying the meastore.uri property
    File hiveSite = new File(newConfFile);
    FileOutputStream out = new FileOutputStream(hiveSite);
    HiveConf.setHiveSiteLocation(oldDefaultHiveSite);
    HiveConf defaultHiveConf = new HiveConf();
    defaultHiveConf.setVar(ConfVars.METASTORE_URIS, "dummyvalue");
    // reset to the hive-site.xml values for following param
    defaultHiveConf.set("hive.dummyparam.test.server.specific.config.override",
        "from.hive-site.xml");
    defaultHiveConf.unset("hive.dummyparam.test.server.specific.config.metastoresite");
    defaultHiveConf.writeXml(out);

    // set the new hive-site.xml
    HiveConf.setHiveSiteLocation(hiveSite.toURI().toURL());
  }
Set new hive-site.xml file location that has remote metastore config

@throws IOException
itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestServerSpecificConfig.java