@Test public void replaceProperty() { VelocityContext context = new VelocityContext(); context.put("xwikiDataDir", "/some/path"); PackageMojo mojo = new PackageMojo(); String content = "" + "# Location where XWiki stores generated data and where database files are.\n" + "XWIKI_DATA_DIR=${xwikiDataDir}\n" + "XWIKI_OPTS=\"$XWIKI_OPTS -Dxwiki.data.dir=$XWIKI_DATA_DIR\"\n" + "XWIKI_PID=$!\n" + "whatever"; String expected = "" + "# Location where XWiki stores generated data and where database files are.\n" + "XWIKI_DATA_DIR=/some/path\n" + "XWIKI_OPTS=\"$XWIKI_OPTS -Dxwiki.data.dir=$XWIKI_DATA_DIR\"\n" + "XWIKI_PID=$!\n" + "whatever"; assertEquals(expected, mojo.replaceProperty(content, context)); }
protected String replaceProperty(String content, VelocityContext velocityContext) { String result = content; for (Object key : velocityContext.getKeys()) { Object value = velocityContext.get(key.toString()); result = StringUtils.replace(result, String.format("${%s}", key.toString()), value.toString()); } return result; }
PackageMojo extends AbstractOldCoreMojo { protected String replaceProperty(String content, VelocityContext velocityContext) { String result = content; for (Object key : velocityContext.getKeys()) { Object value = velocityContext.get(key.toString()); result = StringUtils.replace(result, String.format("${%s}", key.toString()), value.toString()); } return result; } }
PackageMojo extends AbstractOldCoreMojo { protected String replaceProperty(String content, VelocityContext velocityContext) { String result = content; for (Object key : velocityContext.getKeys()) { Object value = velocityContext.get(key.toString()); result = StringUtils.replace(result, String.format("${%s}", key.toString()), value.toString()); } return result; }  }
PackageMojo extends AbstractOldCoreMojo { protected String replaceProperty(String content, VelocityContext velocityContext) { String result = content; for (Object key : velocityContext.getKeys()) { Object value = velocityContext.get(key.toString()); result = StringUtils.replace(result, String.format("${%s}", key.toString()), value.toString()); } return result; }  @Override void executeInternal(); }
PackageMojo extends AbstractOldCoreMojo { protected String replaceProperty(String content, VelocityContext velocityContext) { String result = content; for (Object key : velocityContext.getKeys()) { Object value = velocityContext.get(key.toString()); result = StringUtils.replace(result, String.format("${%s}", key.toString()), value.toString()); } return result; }  @Override void executeInternal();  }