Strings { public static List<String> split(String str, String separator) { if (str == null) { throw new IllegalArgumentException("cannot split null string"); } if (separator == null) { throw new IllegalArgumentException("separator cannot be null"); } if (separator.isEmpty()) { throw new IllegalArgumentException("separator cannot be an empty string"); } return Arrays.asList(str.split(Pattern.quote(separator))); }  static List<String> split(String str, String separator); static String join(String separator, List<String> components); static String join(String separator, String... components);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void splitNullString() { Strings.split(null, "foo"); }
@Test(expectedExceptions = IllegalArgumentException.class) public void splitWithNullSeparator() { Strings.split("foo", null); }
@Test(expectedExceptions = IllegalArgumentException.class) public void splitWithEmptySeparator() { Strings.split("foo", ""); }
@Test public void splitEmptyString() { assertEquals(Strings.split("", ".").size(), 1); }
@Test public void splitSeparatorOnlyString() { assertEquals(Strings.split(".", ".").size(), 0); }
@Test public void noSeparatorInString() { assertEquals(Strings.split("no separator character here", ".").size(), 1); }
@Test public void split() { List<String> l = Strings.split("a.b..c.d", "."); assertEquals(l.size(), 5); assertEquals(l.get(2), ""); }