Util { public static String getSessionDir(String sid) throws IllegalArgumentException { String subdir; if (sid == null) { subdir = null; } else if (sid.length() > 8) { try { DateFormat format = new SimpleDateFormat("yyyyMMdd"); format.parse(sid.substring(0, 8)); subdir = sid.substring(0, 8); } catch (ParseException e) { subdir = sid; } } else { subdir = sid; } return getSessionBaseDir() + "/sessions/" + subdir + "/" + sid; }  static String getAbsRootDir(); static String getSessionBaseDir(); static String getSessionDir(String sid); static String getStack(Exception e); static File[] sortFiles(File[] fs); static void checkSession(String sid); static boolean isWindows(); static String toHumanReadableString(String in); static boolean isIgnoreCharset(String charset); static String toReadableBytes(long bytes); static String toReadableMilliseconds(long millis); static String toReadableNumber(long number); static String pluralize(String word, long count);  }
@Test public void testGetSessionDir() { String path = Util.getSessionBaseDir(); assertEquals("null", path + "/sessions/null/null", Util.getSessionDir(null)); assertEquals("abc", path + "/sessions/abc/abc", Util.getSessionDir("abc")); assertEquals("abcdefghijk", path + "/sessions/abcdefghijk/abcdefghijk", Util.getSessionDir("abcdefghijk")); assertEquals("20141129", path + "/sessions/20141129/20141129", Util.getSessionDir("20141129")); assertEquals("20141131", path + "/sessions/20141131/20141131", Util.getSessionDir("20141131")); assertEquals("20141129abc", path + "/sessions/20141129/20141129abc", Util.getSessionDir("20141129abc")); }