OkapiStringUtil { public static String trimTrailingSlashes(CharSequence s) { if (s == null) { return null; } int end = s.length() - 1; while (end >= 0 && s.charAt(end) == '/') { end--; } return s.subSequence(0, end + 1).toString(); } private  OkapiStringUtil(); static String trimTrailingSlashes(CharSequence s); static String removeLogCharacters(String s);  }
@Test public void trimTrailingSlashes() { Assert.assertEquals(null, OkapiStringUtil.trimTrailingSlashes(null)); Assert.assertEquals("", OkapiStringUtil.trimTrailingSlashes("")); Assert.assertEquals("", OkapiStringUtil.trimTrailingSlashes("/")); Assert.assertEquals("", OkapiStringUtil.trimTrailingSlashes(" Assert.assertEquals("", OkapiStringUtil.trimTrailingSlashes(" Assert.assertEquals("a", OkapiStringUtil.trimTrailingSlashes("a")); Assert.assertEquals("a", OkapiStringUtil.trimTrailingSlashes("a/")); Assert.assertEquals("a", OkapiStringUtil.trimTrailingSlashes("a Assert.assertEquals("a", OkapiStringUtil.trimTrailingSlashes("a Assert.assertEquals("a/b/c", OkapiStringUtil.trimTrailingSlashes("a/b/c")); Assert.assertEquals("a/b/c", OkapiStringUtil.trimTrailingSlashes("a/b/c/")); Assert.assertEquals("a/b/c", OkapiStringUtil.trimTrailingSlashes("a/b/c Assert.assertEquals("a/b/c", OkapiStringUtil.trimTrailingSlashes("a/b/c Assert.assertEquals("/a Assert.assertEquals("/a Assert.assertEquals("/a Assert.assertEquals("/a Assert.assertEquals("/abc/x-y-z/123/c", OkapiStringUtil.trimTrailingSlashes("/abc/x-y-z/123/c")); Assert.assertEquals("/abc/x-y-z/123/c", OkapiStringUtil.trimTrailingSlashes("/abc/x-y-z/123/c/")); Assert.assertEquals("/abc/x-y-z/123/c", OkapiStringUtil.trimTrailingSlashes("/abc/x-y-z/123/c Assert.assertEquals("/abc/x-y-z/123/c", OkapiStringUtil.trimTrailingSlashes("/abc/x-y-z/123/c Assert.assertEquals("\n\r\t ", OkapiStringUtil.trimTrailingSlashes("\n\r\t /")); }