OKW_Helper { public static ArrayList<String> splitString(String fpsString2Split, String fpsSeparator) { ArrayList<String> SplitedList = new ArrayList<String>(); int offset = 0; Log.LogFunctionStartDebug("OKW_Helper.StrSplit", "fpsString2Split", fpsString2Split, "fpsSeparator", fpsSeparator); try { while (true) { int index = fpsString2Split.indexOf(fpsSeparator, offset); if (index == -1) { SplitedList.add(fpsString2Split.substring(offset)); break; } else { SplitedList.add(fpsString2Split.substring(offset, index)); offset = (index + fpsSeparator.length()); } } } finally { Log.LogFunctionEndDebug(SplitedList); } return SplitedList; }  static String Boolean2String( Boolean fpbTrueOrFalse ); static String getLeftFromDelimiterNumber( String fpsSource, String fpsDelimiter, Integer fpiCount ); static String getRightFromDelimiterNumber( String fpsSource, String fpsDelimiter, Integer fpiCount ); static Boolean compareListString( List<String> ListString1, List<String> ListString2 ); static String concatListString( ArrayList<String> fps_ListString2Concat, String fps_Delimiter ); static Boolean matchString( String fpsPattern, String fpsStringToMatch ); static Boolean matchStrIgnoreCase( String fpsPattern, String fpsStringToMatch ); static String removeBeginEndQuotations( String fps_StringinQuotations ); static ArrayList<String> StringArray2ListStr( String[] fpsStringArray ); static Boolean String2Boolean( String fpsTrueOrFalse ); static ArrayList<String> splitString(String fpsString2Split, String fpsSeparator); static String repeatString( char c, Integer n ); static String repeatString( String c, Integer n ); static Boolean isStringNullOrEmpty( String fpsString);  }
@Test public void tcStrSplit() { ArrayList<String> actual = new ArrayList<String>(); ArrayList<String> expected = new ArrayList<String>(); actual = OKW_Helper.splitString("", "/"); expected.clear(); expected.add(""); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root", "/"); expected.clear(); expected.add("Root"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root/", "/"); expected.clear(); expected.add("Root"); expected.add(""); assertEquals(expected, actual); actual = OKW_Helper.splitString("/SubDir_1", "/"); expected.clear(); expected.add(""); expected.add("SubDir_1"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root/SubDir_1", "/"); expected.clear(); expected.add("Root"); expected.add("SubDir_1"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root expected.clear(); expected.add("Root"); expected.add(""); expected.add("Datei"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root/SubDir_1/SubDir_2/Datei", "/"); expected.clear(); expected.add("Root"); expected.add("SubDir_1"); expected.add("SubDir_2"); expected.add("Datei"); assertEquals(expected, actual); }
@Test public void tcStrSplit_Wert() { ArrayList<String> actual = new ArrayList<String>(); ArrayList<String> expected = new ArrayList<String>(); actual = OKW_Helper.splitString("", "${WERT}"); expected.clear(); expected.add(""); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root", "{WERT}"); expected.clear(); expected.add("Root"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root${WERT}", "${WERT}"); expected.clear(); expected.add("Root"); expected.add(""); assertEquals(expected, actual); actual = OKW_Helper.splitString("${WERT}SubDir_1", "${WERT}"); expected.clear(); expected.add(""); expected.add("SubDir_1"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root${WERT}SubDir_1", "${WERT}"); expected.clear(); expected.add("Root"); expected.add("SubDir_1"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root${WERT}${WERT}Datei", "${WERT}"); expected.clear(); expected.add("Root"); expected.add(""); expected.add("Datei"); assertEquals(expected, actual); actual = OKW_Helper.splitString("Root${WERT}SubDir_1${WERT}SubDir_2${WERT}Datei", "${WERT}"); expected.clear(); expected.add("Root"); expected.add("SubDir_1"); expected.add("SubDir_2"); expected.add("Datei"); assertEquals(expected, actual); }