@Test public void testUpdateAmsHbaseEnvContent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method updateAmsHbaseEnvContent = UpgradeCatalog221.class.getDeclaredMethod("updateAmsHbaseEnvContent", String.class); UpgradeCatalog221 upgradeCatalog221 = new UpgradeCatalog221(injector); String oldContent = "some_content\n" + "{% if security_enabled %}\n" + "export HBASE_OPTS=\"$HBASE_OPTS -Djava.security.auth.login.config={{client_jaas_config_file}} -Dzookeeper.sasl.client.username={{zk_servicename}}\"\n" + "export HBASE_MASTER_OPTS=\"$HBASE_MASTER_OPTS -Djava.security.auth.login.config={{master_jaas_config_file}} -Dzookeeper.sasl.client.username={{zk_servicename}}\"\n" + "export HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS -Djava.security.auth.login.config={{regionserver_jaas_config_file}} -Dzookeeper.sasl.client.username={{zk_servicename}}\"\n" + "export HBASE_ZOOKEEPER_OPTS=\"$HBASE_ZOOKEEPER_OPTS -Djava.security.auth.login.config={{ams_zookeeper_jaas_config_file}} -Dzookeeper.sasl.client.username={{zk_servicename}}\"\n" + "{% endif %}"; String expectedContent = "some_content\n" + "{% if security_enabled %}\n" + "export HBASE_OPTS=\"$HBASE_OPTS -Djava.security.auth.login.config={{client_jaas_config_file}}\"\n" + "export HBASE_MASTER_OPTS=\"$HBASE_MASTER_OPTS -Djava.security.auth.login.config={{master_jaas_config_file}}\"\n" + "export HBASE_REGIONSERVER_OPTS=\"$HBASE_REGIONSERVER_OPTS -Djava.security.auth.login.config={{regionserver_jaas_config_file}}\"\n" + "export HBASE_ZOOKEEPER_OPTS=\"$HBASE_ZOOKEEPER_OPTS -Djava.security.auth.login.config={{ams_zookeeper_jaas_config_file}}\"\n" + "{% endif %}"; String result = (String) updateAmsHbaseEnvContent.invoke(upgradeCatalog221, oldContent); Assert.assertEquals(expectedContent, result); }
protected String updateAmsHbaseEnvContent(String content) { if (content == null) { return null; } String regSearch = "_jaas_config_file\\}\\} -Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsHbaseEnvContent(String content) { if (content == null) { return null; } String regSearch = "_jaas_config_file\\}\\} -Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsHbaseEnvContent(String content) { if (content == null) { return null; } String regSearch = "_jaas_config_file\\}\\} -Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } @Inject  UpgradeCatalog221(Injector injector); }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsHbaseEnvContent(String content) { if (content == null) { return null; } String regSearch = "_jaas_config_file\\}\\} -Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } @Inject  UpgradeCatalog221(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsHbaseEnvContent(String content) { if (content == null) { return null; } String regSearch = "_jaas_config_file\\}\\} -Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } @Inject  UpgradeCatalog221(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion();  }