@Test public void testURLWithImpersonationPropertyEnd() throws Exception { String url = "jdbc:hive2: assertEquals("jdbc:hive2: HiveJdbcUtils.updateImpersonationPropertyInHiveJdbcUrl(url, "foo")); }
public static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user) { String suffix, prefix = null; int terminatorIndex = findTerminatorIndex(url, 0, TERMINATORS_TWO_CHARS); int impersonationPropertyIndex = url.indexOf(HIVE_URL_IMPERSONATION_PROPERTY); if (impersonationPropertyIndex > -1 && (terminatorIndex == -1 || impersonationPropertyIndex < terminatorIndex)) { prefix = url.substring(0, impersonationPropertyIndex); terminatorIndex = findTerminatorIndex(url, impersonationPropertyIndex + HIVE_URL_IMPERSONATION_PROPERTY.length(), TERMINATORS_THREE_CHARS); } suffix = terminatorIndex < 0 ? "" : url.substring(terminatorIndex); if (prefix == null) { prefix = terminatorIndex < 0 ? url : url.substring(0, terminatorIndex); } return String.format("%s%s=%s%s", StringUtils.removeEnd(prefix, ";"), HIVE_URL_IMPERSONATION_PROPERTY, user, suffix); }
HiveJdbcUtils { public static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user) { String suffix, prefix = null; int terminatorIndex = findTerminatorIndex(url, 0, TERMINATORS_TWO_CHARS); int impersonationPropertyIndex = url.indexOf(HIVE_URL_IMPERSONATION_PROPERTY); if (impersonationPropertyIndex > -1 && (terminatorIndex == -1 || impersonationPropertyIndex < terminatorIndex)) { prefix = url.substring(0, impersonationPropertyIndex); terminatorIndex = findTerminatorIndex(url, impersonationPropertyIndex + HIVE_URL_IMPERSONATION_PROPERTY.length(), TERMINATORS_THREE_CHARS); } suffix = terminatorIndex < 0 ? "" : url.substring(terminatorIndex); if (prefix == null) { prefix = terminatorIndex < 0 ? url : url.substring(0, terminatorIndex); } return String.format("%s%s=%s%s", StringUtils.removeEnd(prefix, ";"), HIVE_URL_IMPERSONATION_PROPERTY, user, suffix); } }
HiveJdbcUtils { public static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user) { String suffix, prefix = null; int terminatorIndex = findTerminatorIndex(url, 0, TERMINATORS_TWO_CHARS); int impersonationPropertyIndex = url.indexOf(HIVE_URL_IMPERSONATION_PROPERTY); if (impersonationPropertyIndex > -1 && (terminatorIndex == -1 || impersonationPropertyIndex < terminatorIndex)) { prefix = url.substring(0, impersonationPropertyIndex); terminatorIndex = findTerminatorIndex(url, impersonationPropertyIndex + HIVE_URL_IMPERSONATION_PROPERTY.length(), TERMINATORS_THREE_CHARS); } suffix = terminatorIndex < 0 ? "" : url.substring(terminatorIndex); if (prefix == null) { prefix = terminatorIndex < 0 ? url : url.substring(0, terminatorIndex); } return String.format("%s%s=%s%s", StringUtils.removeEnd(prefix, ";"), HIVE_URL_IMPERSONATION_PROPERTY, user, suffix); }  }
HiveJdbcUtils { public static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user) { String suffix, prefix = null; int terminatorIndex = findTerminatorIndex(url, 0, TERMINATORS_TWO_CHARS); int impersonationPropertyIndex = url.indexOf(HIVE_URL_IMPERSONATION_PROPERTY); if (impersonationPropertyIndex > -1 && (terminatorIndex == -1 || impersonationPropertyIndex < terminatorIndex)) { prefix = url.substring(0, impersonationPropertyIndex); terminatorIndex = findTerminatorIndex(url, impersonationPropertyIndex + HIVE_URL_IMPERSONATION_PROPERTY.length(), TERMINATORS_THREE_CHARS); } suffix = terminatorIndex < 0 ? "" : url.substring(terminatorIndex); if (prefix == null) { prefix = terminatorIndex < 0 ? url : url.substring(0, terminatorIndex); } return String.format("%s%s=%s%s", StringUtils.removeEnd(prefix, ";"), HIVE_URL_IMPERSONATION_PROPERTY, user, suffix); }  static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user); }
HiveJdbcUtils { public static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user) { String suffix, prefix = null; int terminatorIndex = findTerminatorIndex(url, 0, TERMINATORS_TWO_CHARS); int impersonationPropertyIndex = url.indexOf(HIVE_URL_IMPERSONATION_PROPERTY); if (impersonationPropertyIndex > -1 && (terminatorIndex == -1 || impersonationPropertyIndex < terminatorIndex)) { prefix = url.substring(0, impersonationPropertyIndex); terminatorIndex = findTerminatorIndex(url, impersonationPropertyIndex + HIVE_URL_IMPERSONATION_PROPERTY.length(), TERMINATORS_THREE_CHARS); } suffix = terminatorIndex < 0 ? "" : url.substring(terminatorIndex); if (prefix == null) { prefix = terminatorIndex < 0 ? url : url.substring(0, terminatorIndex); } return String.format("%s%s=%s%s", StringUtils.removeEnd(prefix, ";"), HIVE_URL_IMPERSONATION_PROPERTY, user, suffix); }  static String updateImpersonationPropertyInHiveJdbcUrl(String url, String user);  }