### Question:
StringUtils { public static String[] splitBySlash(final String s) { if (s == null || isBlank(s)) { return new String[0]; } char[] chars = s.toCharArray(); int numberOfSegments = countSlashes(s) + 1; final String[] segments = new String[numberOfSegments]; int currentSegmentIndex = 0; int lastSlashIndex = -1; for (int i = 0; i < chars.length; ++i) { if (chars[i] == '/') { segments[currentSegmentIndex] = new String(chars, lastSlashIndex + 1, i - lastSlashIndex - 1); ++currentSegmentIndex; lastSlashIndex = i; } } if (lastSlashIndex + 1 < chars.length) { segments[currentSegmentIndex] = new String(chars, lastSlashIndex + 1, chars.length - lastSlashIndex - 1); } else { segments[currentSegmentIndex] = ""; } return segments; }  static boolean isBlank(String s); static boolean isNotBlank(String s); static boolean hasLeadingSlash(final String s); static boolean hasTrailingSlash(final String s); static String[] splitBySlash(final String s); static int countSlashes(final String s); static String removePathPrefix(String prefix, String url);  }### Answer:
@Test public void testSplitBySlash() { assertArrayEquals(new String[0], StringUtils.splitBySlash(null)); assertArrayEquals(new String[0], StringUtils.splitBySlash("")); assertArrayEquals(new String[] { "test" }, StringUtils.splitBySlash("test")); assertArrayEquals(new String[] { "a", "b" }, StringUtils.splitBySlash("a/b")); assertArrayEquals(new String[] { "a", "b", "c" }, StringUtils.splitBySlash("a/b/c")); assertArrayEquals(new String[] { "", "test" }, StringUtils.splitBySlash("/test")); assertArrayEquals(new String[] { "test", "" }, StringUtils.splitBySlash("test/")); assertArrayEquals(new String[] { "", "test", "" }, StringUtils.splitBySlash("/test/")); assertArrayEquals(new String[] { "", "" }, StringUtils.splitBySlash("/")); assertArrayEquals(new String[] { "", "", "" }, StringUtils.splitBySlash(" assertArrayEquals(new String[] { "", "", "test" }, StringUtils.splitBySlash(" assertArrayEquals(new String[] { "test", "", "" }, StringUtils.splitBySlash("test assertArrayEquals(new String[] { "", "", "test", "", "" }, StringUtils.splitBySlash(" assertArrayEquals(new String[] { "", "a", "b" }, StringUtils.splitBySlash("/a/b")); assertArrayEquals(new String[] { "a", "", "b" }, StringUtils.splitBySlash("a assertArrayEquals(new String[] { "a", "b", "" }, StringUtils.splitBySlash("a/b/")); assertArrayEquals(new String[] { "", "a", "", "b", "" }, StringUtils.splitBySlash("/a assertArrayEquals(new String[] { "", "a", "b", "c" }, StringUtils.splitBySlash("/a/b/c")); assertArrayEquals(new String[] { "a", "", "b", "c" }, StringUtils.splitBySlash("a assertArrayEquals(new String[] { "a", "b", "", "c" }, StringUtils.splitBySlash("a/b assertArrayEquals(new String[] { "a", "b", "c", "" }, StringUtils.splitBySlash("a/b/c/")); assertArrayEquals(new String[] { "", "a", "", "b", "", "c", "" }, StringUtils.splitBySlash("/a }