### Question:
Util { static String stripLeadingAndTrailingQuotes(String str) { int length = str.length(); if (length > 1 && str.startsWith("\"") && str.endsWith("\"") && str.substring(1, length - 1).indexOf('"') == -1) { str = str.substring(1, length - 1); } return str; }    }### Answer:
@Test public void testStripLeadingAndTrailingQuotes() { assertEquals("foo", Util.stripLeadingAndTrailingQuotes("\"foo\"")); assertEquals("foo \"bar\"", Util.stripLeadingAndTrailingQuotes("foo \"bar\"")); assertEquals("\"foo\" bar", Util.stripLeadingAndTrailingQuotes("\"foo\" bar")); assertEquals("\"foo\" and \"bar\"", Util.stripLeadingAndTrailingQuotes("\"foo\" and \"bar\"")); assertEquals("\"", Util.stripLeadingAndTrailingQuotes("\"")); }