@Test public void testUpdateAmsEnvContent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method updateAmsEnvContent = UpgradeCatalog221.class.getDeclaredMethod("updateAmsEnvContent", String.class); UpgradeCatalog221 upgradeCatalog221 = new UpgradeCatalog221(injector); String oldContent = "some_content\n" + "# AMS Collector options\n" + "export AMS_COLLECTOR_OPTS=\"-Djava.library.path=/usr/lib/ams-hbase/lib/hadoop-native\"\n" + "{% if security_enabled %}\n" + "export AMS_COLLECTOR_OPTS=\"$AMS_COLLECTOR_OPTS -Djava.security.auth.login.config={{ams_collector_jaas_config_file}} " + "-Dzookeeper.sasl.client.username={{zk_servicename}}\"\n" + "{% endif %}"; String expectedContent = "some_content\n" + "# AMS Collector options\n" + "export AMS_COLLECTOR_OPTS=\"-Djava.library.path=/usr/lib/ams-hbase/lib/hadoop-native\"\n" + "{% if security_enabled %}\n" + "export AMS_COLLECTOR_OPTS=\"$AMS_COLLECTOR_OPTS -Djava.security.auth.login.config={{ams_collector_jaas_config_file}}\"\n" + "{% endif %}"; String result = (String) updateAmsEnvContent.invoke(upgradeCatalog221, oldContent); Assert.assertEquals(expectedContent, result); }
protected String updateAmsEnvContent(String content) { if (content == null) { return null; } String regSearch = "-Djava.security.auth.login.config=\\{\\{ams_collector_jaas_config_file\\}\\} " + "-Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "-Djava.security.auth.login.config={{ams_collector_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsEnvContent(String content) { if (content == null) { return null; } String regSearch = "-Djava.security.auth.login.config=\\{\\{ams_collector_jaas_config_file\\}\\} " + "-Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "-Djava.security.auth.login.config={{ams_collector_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsEnvContent(String content) { if (content == null) { return null; } String regSearch = "-Djava.security.auth.login.config=\\{\\{ams_collector_jaas_config_file\\}\\} " + "-Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "-Djava.security.auth.login.config={{ams_collector_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } @Inject  UpgradeCatalog221(Injector injector); }
UpgradeCatalog221 extends AbstractUpgradeCatalog { protected String updateAmsEnvContent(String content) { if (content == null) { return null; } String regSearch = "-Djava.security.auth.login.config=\\{\\{ams_collector_jaas_config_file\\}\\} " + "-Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "-Djava.security.auth.login.config={{ams_collector_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 updateAmsEnvContent(String content) { if (content == null) { return null; } String regSearch = "-Djava.security.auth.login.config=\\{\\{ams_collector_jaas_config_file\\}\\} " + "-Dzookeeper.sasl.client.username=\\{\\{zk_servicename\\}\\}"; String replacement = "-Djava.security.auth.login.config={{ams_collector_jaas_config_file}}"; content = content.replaceAll(regSearch, replacement); return content; } @Inject  UpgradeCatalog221(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion();  }