ConfigTemplate { protected static String escapeMultilineQuotes(String quoteVariant, String value) { if ("'''".equals(quoteVariant) || "\"\"\"".equals(quoteVariant)) { return value.replace(quoteVariant, new String(new char[3]).replace("\0", "\\" + quoteVariant.charAt(0))); } else { throw new IllegalArgumentException("Only a valid Turtle multi-line quote delmiter is allowed."); } } ConfigTemplate(String template); String getTemplate(); final void setTemplate(String template); Map<String, List<String>> getVariableMap(); String render(Map<String, String> valueMap); Map<String, String> getMultilineMap();  }
@Test public final void testNonEscapeOfAlternateMultilineDelimiter() { String value = "I contain a '''multiline\nstring''' that shouldn't be escaped."; assertEquals(ConfigTemplate.escapeMultilineQuotes("\"\"\"", value), value); value = "I contain a \"\"\"multiline\nstring\"\"\" that shouldn't be escaped."; assertEquals(ConfigTemplate.escapeMultilineQuotes("'''", value), value); }
@Test public final void testEscapeOfSpecifiedMultilineDelimiter() { String value = "I contain a '''multiline\nstring''' that should be escaped."; assertEquals(ConfigTemplate.escapeMultilineQuotes("'''", value), "I contain a \\'\\'\\'multiline\nstring\\'\\'\\' that should be escaped."); value = "I contain a \"\"\"multiline\nstring\"\"\" that should be escaped."; assertEquals(ConfigTemplate.escapeMultilineQuotes("\"\"\"", value), "I contain a \\\"\\\"\\\"multiline\nstring\\\"\\\"\\\" that should be escaped."); }
@Test public final void testNonEscapeOfShorterSequences() { String value = "' '' ''' ''''"; assertEquals(ConfigTemplate.escapeMultilineQuotes("'''", value), "' '' \\'\\'\\' \\'\\'\\''"); value = "\" \"\" \"\"\" \"\"\"\""; assertEquals(ConfigTemplate.escapeMultilineQuotes("\"\"\"", value), "\" \"\" \\\"\\\"\\\" \\\"\\\"\\\"\""); }
@Test(expected = IllegalArgumentException.class) public final void testInvalidDelimiterThrowsException() { ConfigTemplate.escapeMultilineQuotes("'", "any value"); }