FtpHelper { public static String getDirectory(String s, boolean windows) { String result = s; int slashPos = lastSlash(s, windows); if (slashPos >= 0) { result = s.substring(0, slashPos); } return result; }  static String getFilename(String s, boolean windowsWorkaround); static String getDirectory(String s, boolean windows); static String getFilename(String fullPath); static String getDirectory(String fullPath); static final String FORWARD_SLASH; static final String BACK_SLASH; }
@Test public void testGetDirectory() { String directory = getDirectory(UNIX_PATH); assertEquals(UNIX_DIR, directory); directory = getDirectory(UNIX_PATH, true); assertNotEquals(UNIX_DIR, directory); assertEquals(UNIX_PATH, directory); directory = getDirectory(WINDOWS_PATH, true); assertEquals(WINDOWS_DIR, directory); directory = getDirectory(WINDOWS_PATH, false); assertNotEquals(WINDOWS_DIR, directory); assertEquals(WINDOWS_PATH, directory); }