/** * Tests creating file in appropriate local directory. * * @throws Exception unexpected */ @Test public void test04CanCreateFileInNewLocalDirectory() throws Exception { session.changeLocalDirectory(System.getProperty("user.dir")); testDir = new File(session.getLocalDirectory(), "goodSessionTestDir"); testDir.mkdir(); testDir.deleteOnExit(); session.changeLocalDirectory(testDir.getPath()); File testfile = new File(session.getLocalDirectory(), "goodSessionTest04"); testfile.createNewFile(); testfile.deleteOnExit(); assertTrue(testfile.getAbsolutePath().contains(testDir.getAbsolutePath())); // Force deletion now so we can delete containing directory later. assertTrue(testfile.delete()); }
/** * Tests sane default for local directory if directory no longer exists. * * @throws Exception */ @Test public void test08RestoreCanRevertToDefaultLocalIfLocalDirIsRemoved() throws Exception { assertTrue(testDir.delete()); session.disconnect(); session.restore(); assertTrue(session.getLocalDirectory().equals(System.getProperty("user.dir"))); }