HadoopSecureHiveWrapper { static Map<String, String> getHiveVarMap(String[] args) { if (args == null) { return Collections.emptyMap(); } Map<String, String> hiveVarMap = new HashMap<String, String>(); for (int index = 0; index < args.length; index++) { if ("-hivevar".equals(args[index])) { String hiveVarParam = stripSingleDoubleQuote(args[++index]); int gap = hiveVarParam.indexOf("="); if (gap == -1) { logger.warn("Invalid hivevar: " + hiveVarParam); continue; } String name = hiveVarParam.substring(0, gap); String value = hiveVarParam.substring(gap + 1); logger.info("Setting hivevar: " + name + "=" + value); hiveVarMap.put(name, value); } } return hiveVarMap; }  static void main(final String[] args); static void runHive(String[] args);  }
@Test public void testParamsWithEqualSigns() { String[] args = {"-hivevar", "'testKey1=testVal1'", "-hivevar", "'testKey2=testVal2==something=anything'", "-hivevar", "'testKey3=testVal3=anything'"}; Map<String, String> hiveVarMap = HadoopSecureHiveWrapper.getHiveVarMap(args); Assert.assertTrue(hiveVarMap.size() == 3); Assert.assertTrue(hiveVarMap.get("testKey1").equals("testVal1")); Assert.assertTrue(hiveVarMap.get("testKey2").equals("testVal2==something=anything")); Assert.assertTrue(hiveVarMap.get("testKey3").equals("testVal3=anything")); }