@Test @Parameters(method = "specialCharacters") public void should_escape_special_characters(String specialCharacters, String expectedEscaped) throws Exception { final String escaped = new SpecialCharactersReplacer().escape(specialCharacters); assertThat(escaped).isEqualTo(expectedEscaped); }
public String escape(String source) { String result = source.replaceAll("(?m)&(.[a-zA-Z0-9]*);", "ape_special[$1]"); result = result.replace("\\{", "ape_especial_curly_brackets_begin"); result = result.replace("\\}", "ape_especial_curly_brackets_end"); return result; }
SpecialCharactersReplacer { public String escape(String source) { String result = source.replaceAll("(?m)&(.[a-zA-Z0-9]*);", "ape_special[$1]"); result = result.replace("\\{", "ape_especial_curly_brackets_begin"); result = result.replace("\\}", "ape_especial_curly_brackets_end"); return result; } }
SpecialCharactersReplacer { public String escape(String source) { String result = source.replaceAll("(?m)&(.[a-zA-Z0-9]*);", "ape_special[$1]"); result = result.replace("\\{", "ape_especial_curly_brackets_begin"); result = result.replace("\\}", "ape_especial_curly_brackets_end"); return result; }  }
SpecialCharactersReplacer { public String escape(String source) { String result = source.replaceAll("(?m)&(.[a-zA-Z0-9]*);", "ape_special[$1]"); result = result.replace("\\{", "ape_especial_curly_brackets_begin"); result = result.replace("\\}", "ape_especial_curly_brackets_end"); return result; }  String escape(String source); String unescape(String source); }
SpecialCharactersReplacer { public String escape(String source) { String result = source.replaceAll("(?m)&(.[a-zA-Z0-9]*);", "ape_special[$1]"); result = result.replace("\\{", "ape_especial_curly_brackets_begin"); result = result.replace("\\}", "ape_especial_curly_brackets_end"); return result; }  String escape(String source); String unescape(String source);  }