### Question:
StringUtils { public static String tryTrim(String string) { if (string == null) return null; return string.trim(); } private  StringUtils(); static String byteToHex(byte[] data); static String replaceLineBreaksWithSpace(String string); static String collapseLineBreaks(String string); static String replaceLineBreaks(String string, String replace); static String removeWhiteSpaces(String string); static String tryTrim(String string); static int getLevenshteinDistance(CharSequence s, CharSequence t); static String join(Object[] array, char separator); static String join(Object[] array, char separator, int startIndex, int endIndex); static String join(Iterator<T> iterator, String separator); static String join(Collection<T> collection, String separator); static final String EMPTY; static final String SPACE; }### Answer:
@Test public void testTryTrim() { Assert.assertNull(StringUtils.tryTrim(null)); Assert.assertEquals("", StringUtils.tryTrim("")); Assert.assertEquals("foobar", StringUtils.tryTrim("foobar")); Assert.assertEquals("foo bar", StringUtils.tryTrim("foo bar")); Assert.assertEquals("foo bar", StringUtils.tryTrim("foo bar")); Assert.assertEquals("foo bar", StringUtils.tryTrim(" foo bar ")); Assert.assertEquals("foo\nbar", StringUtils.tryTrim("foo\nbar")); Assert.assertEquals("foo\n\nbar", StringUtils.tryTrim("foo\n\nbar")); Assert.assertEquals("foo\rbar", StringUtils.tryTrim("foo\rbar")); Assert.assertEquals("foo\r\n bar", StringUtils.tryTrim("foo\r\n bar")); Assert.assertEquals("foo\r\nbar", StringUtils.tryTrim("foo\r\nbar\n")); Assert.assertEquals("foo\n bar", StringUtils.tryTrim("\rfoo\n bar")); Assert.assertEquals("foo bar", StringUtils.tryTrim("\rfoo bar\n")); }