public void testExplode(){
  String[] testStrings={"a:b","ab:cd","ab::cd",":ab:cd","ab:cd:",":ab:cd:","::ab::cd::","a","ab",""};
  for (  String test : testStrings) {
    String[] resultExplode=StringUtils.explode(test,':');
    String[] resultSplit=test.split(":");
    assertEquals("Different result lengths with test string \"" + test + "\"",resultSplit.length,resultExplode.length);
    for (int i=0; i < resultExplode.length; i++) {
      assertEquals("Different result part " + i + " when testing string: \""+ test+ "\"",resultSplit[i],resultExplode[i]);
    }
  }
}

public void testExplode ( ) { String [ ] testStrings = { "a:b" , "ab:cd" , "ab::cd" , ":ab:cd" , "ab:cd:" , ":ab:cd:" , "::ab::cd::" , "a" , "ab" , "" } ; for ( String test : testStrings ) { String [ ] resultExplode = StringUtils . explode ( test , ':' ) ; String [ ] resultSplit = test . split ( ":" ) ; assertEquals ( "Different result lengths with test string \"" + test + "\"" , resultSplit . length , resultExplode . length ) ; for ( int i = 0 ; i < resultExplode . length ; i ++ ) { assertEquals ( "Different result part " + i + " when testing string: \"" + test + "\"" , resultSplit [ i ] , resultExplode [ i ] ) ; } } }
tests the method explode ( string , char ) , which should always return the same as string . split ( string ) does .
