Utils { public static String replaceXPath(String input, String name, boolean debug) { if (null == input) { return null; } Matcher matcher = (Pattern.compile("\\[text\\(\\)='(?:\\w+)'\\]")) .matcher(input); if (debug) { if (!matcher.find()) { return null; } } return matcher.replaceAll(String.format("[text()='%s']", name)); }  static String resolveEnvVars(String input); static String replaceXPath(String input, String name, boolean debug); static String replaceXPath(String input, String tag1, String tag2,
			String name, boolean debug); static String replaceXPath(String input, String prefix, String tag1,
			String tag2, String name, boolean debug);  }
@Test public void xpathReplaceNameTest() { String result = Utils.replaceXPath(resource, "dummy", true); assertThat(result, notNullValue()); assertThat(result, containsString("dummy")); if (debug) { System.err.println("xpathReplaceNameTest result: " + result); } }
@Test public void xpathReplaceTagNameTest() { String result = Utils.replaceXPath(resource, "tag", "tag-info", "dummy", true); assertThat(result, notNullValue()); assertThat(result, containsString("tag")); assertThat(result, containsString("tag-info")); assertThat(result, containsString("dummy")); if (debug) { System.err.println("xpathReplaceTagNameTest result: " + result); } }
@Test public void xpathReplacePrefixTagNameTest() { String result = Utils.replaceXPath(resource, "prefix", "tag", "tag-info", "dummy", true); assertThat(result, notNullValue()); assertThat(result, containsString("prefix:tag")); assertThat(result, containsString("prefix:tag-info")); assertThat(result, containsString("dummy")); if (debug) { System.err.println("xpathReplacePrefixTagNameTest result: " + result); } }