### Question:
StringUtils { public static String stripComments(String multiLineSQL) { String strippedSingleLines = Pattern.compile("(.*?)\\s*\\-\\-.*\n").matcher(multiLineSQL).replaceAll("$1\n"); strippedSingleLines = Pattern.compile("(.*?)\\s*\\-\\-.*$").matcher(strippedSingleLines).replaceAll("$1\n"); return Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL).matcher(strippedSingleLines).replaceAll("").trim(); }  static String trimToEmpty(String string); static String trimToNull(String string); static String[] processMutliLineSQL(String multiLineSQL,boolean stripComments, boolean splitStatements, String endDelimiter); static String[] splitSQL(String multiLineSQL, String endDelimiter); static String stripComments(String multiLineSQL); static String join(String[] array, String delimiter); static String join(Collection<String> collection, String delimiter); static List<String> splitAndTrim(String s, String regex); static String repeat(String string, int times); static String join(Integer[] array, String delimiter); static String join(int[] array, String delimiter);  }### Answer:
@Test public void multiLineAfterSQL() { String sql = "some sql"; String comment = "" ; String total = sql + comment; String result = StringUtils.stripComments(total); assertEquals(sql.trim(),result); }
@Test public void multiLineFinishesWithTextOnLine() { String sql = "some sql"; String comment = "" ; String total = comment + sql; String result = StringUtils.stripComments(total); assertEquals(sql.trim(),result); }
@Test public void multiLineStartAndFinishWithSQL() { String sql = "some sql"; String comment = "" ; String total = sql + comment + sql; String result = StringUtils.stripComments(total); assertEquals(sql.trim() + sql,result); }
@Test public void noComments() { String noComments=" Some text but no comments"; String result = StringUtils.stripComments(noComments); assertEquals(noComments.trim(),result); }
@Test public void singleLineNoNewLine() { String sql = "Some text" ; String comment = " -- with comment"; String totalLine=sql + comment ; String result = StringUtils.stripComments(totalLine); assertEquals(sql,result); }
@Test public void singleLineNoFollowOnLine() { String sql = "Some text" ; String comment = " -- with comment\n"; String totalLine=sql + comment ; String result = StringUtils.stripComments(totalLine); assertEquals(sql.trim(),result); }
@Test public void singleLineMultipleComments() { String sql = "Some text" ; String comment = " -- with comment"; String totalLine=sql + comment + "\n"+ sql + comment ; String result = StringUtils.stripComments(totalLine); assertEquals(sql+"\n"+sql,result); }
@Test public void singleLineWithFollowupLine() { String sql = "Some text" ; String comment = " -- with comment"; String totalLine=sql + comment + "\n" + sql ; String result = StringUtils.stripComments(totalLine); assertEquals(sql + "\n" + sql,result); }
@Test public void multiLineOnOwnLine() { String sql = "" ; String result = StringUtils.stripComments(sql); assertEquals("",result); }