UpgradeCatalog220 extends AbstractUpgradeCatalog { protected String updateAmsHbaseEnvContent(String content) { if (content == null) { return null; } String regSearch = "export HBASE_HEAPSIZE="; String replacement = "#export HBASE_HEAPSIZE="; content = content.replaceAll(regSearch, replacement); content += "\n" + "# The maximum amount of heap to use for hbase shell.\n" + "export HBASE_SHELL_OPTS=\"-Xmx256m\"\n"; return content; } @Inject  UpgradeCatalog220(Injector injector); @Override String getTargetVersion(); @Override String getSourceVersion(); @Transactional void bootstrapRepoVersionForHDP21(); static final String UPGRADE_PACKAGE_COL; static final String UPGRADE_TYPE_COL; static final String REPO_VERSION_TABLE; }
@Test public void testUpdateAmsHbaseEnvContent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { Method updateAmsHbaseEnvContent = UpgradeCatalog220.class.getDeclaredMethod("updateAmsHbaseEnvContent", String.class); UpgradeCatalog220 upgradeCatalog220 = new UpgradeCatalog220(injector); String oldContent = "export HBASE_CLASSPATH=${HBASE_CLASSPATH}\n" + "\n" + "# The maximum amount of heap to use, in MB. Default is 1000.\n" + "export HBASE_HEAPSIZE={{hbase_heapsize}}\n"; String expectedContent = "export HBASE_CLASSPATH=${HBASE_CLASSPATH}\n" + "\n" + "# The maximum amount of heap to use, in MB. Default is 1000.\n" + "#export HBASE_HEAPSIZE={{hbase_heapsize}}\n" + "\n" + "# The maximum amount of heap to use for hbase shell.\n" + "export HBASE_SHELL_OPTS=\"-Xmx256m\"\n"; String result = (String) updateAmsHbaseEnvContent.invoke(upgradeCatalog220, oldContent); Assert.assertEquals(expectedContent, result); }