StringTools { public static String appendToPath(final String basePath, final String additionalPath) { String tmpAdditionalPath; if (additionalPath.startsWith("\\") || additionalPath.startsWith("/")) { tmpAdditionalPath = additionalPath.substring(1); } else { tmpAdditionalPath = additionalPath; } return FilenameUtils.concat(basePath, tmpAdditionalPath); } private  StringTools(); static String characterMapReplacement(Character charToReplace); static String stringMapReplacement(String stringToReplace); static String appendToPath(final String basePath, final String additionalPath); static String cleanString(String sourceString); static String formatFileSize(long fileSize); static boolean isNotValidString(String testString); static boolean isValidString(String testString); static String trimToLength(String sourceString, int requiredLength); static String trimToLength(String sourceString, int requiredLength, boolean trimToWord, String endingSuffix); static List<T> castList(Class<? extends T> objClass, Collection<?> c); static List<String> splitList(String stringToSplit, String regexDelim); static String[] tokenizeToArray(String sourceString, String delimiter); static String processMpaaCertification(String mpaaCertification); static String processMpaaCertification(String mpaaRated, String mpaaCertification); static String replaceQuotes(String original); static int parseRating(String rating); static int parseRating(float rating); static String getWords(final String sentanceToTrim, int numOfWords);  }
@Test public void testAppendToPath() { LOG.info("appendToPath"); List<String[]> tests = new ArrayList<>(); tests.add(new String[]{"base", "additional", "base" + File.separator + "additional"}); tests.add(new String[]{"\\base", "additional", "" + File.separator + "base" + File.separator + "additional"}); tests.add(new String[]{"/base", "additional", "" + File.separator + "base" + File.separator + "additional"}); tests.add(new String[]{"base", "\\additional", "base" + File.separator + "additional"}); tests.add(new String[]{"base", "/additional", "base" + File.separator + "additional"}); String base, additional, actual, expected; int count = 1; for (String[] test : tests) { base = test[0]; additional = test[1]; expected = test[2]; LOG.info("Test #{}: '{}' + '{}'", count, base, additional); actual = StringTools.appendToPath(base, additional); LOG.info("Test #{}: '{}'", count, actual); assertEquals("Failed appendToPath, test #" + count, expected, actual); count++; } }