### Question:
StringTools { public static String cleanControlChars(String inInput, boolean inRemoveTabAndLf, boolean inRemoveSurroundingQuotes) { if (inInput == null) { return net.violet.common.StringShop.EMPTY_STRING; } final Pattern cleanPattern = (inRemoveTabAndLf ? StringTools.ALL_CTL_CHARS : StringTools.CTL_CHARS); final String firstPass = cleanPattern.matcher(inInput).replaceAll(net.violet.common.StringShop.EMPTY_STRING); if (inRemoveSurroundingQuotes) { return StringTools.SURR_QUOTES.matcher(firstPass).replaceAll(net.violet.common.StringShop.EMPTY_STRING); } return firstPass; }  static String cleanControlChars(String inInput, boolean inRemoveTabAndLf, boolean inRemoveSurroundingQuotes); static String cr2br(String inInput); static String unescapeString(String myString); static String truncate(String inString, int inMaxSize); static String truncate(String inString, int inMaxSize, String inEndMarker); static String getFirstSentence(String text, int maxLength);  }### Answer:
@Test public void testCleanControlChars() { final String bad = "\tI'm \r\nbad\r baby\n"; final String almostgood = StringTools.cleanControlChars(bad, false, false); Assert.assertEquals("\tI'm \nbad baby\n", almostgood); final String reallygood = StringTools.cleanControlChars(bad, true, true); Assert.assertEquals("I'm bad baby", reallygood); }
@Test public void testCleanSurroundingQuotes() { String bad = "''I'm bad baby'' '"; String reallygood = StringTools.cleanControlChars(bad, true, true); Assert.assertEquals("I'm bad baby", reallygood); bad = "''I'm bad ' baby"; reallygood = StringTools.cleanControlChars(bad, true, true); Assert.assertEquals("I'm bad ' baby", reallygood); }
@Test public void testFullClean() { final String bad = "'\t'I'm\r bad\r baby'' '"; final String reallygood = StringTools.cleanControlChars(bad, true, true); Assert.assertEquals("I'm bad baby", reallygood); }