コード例 #1
0
 /** Test attempt to change remote directory to a nonexistent directory. */
 @Test
 public void test05ChangeRemoteDirWithBadDirFails() throws Exception {
   session.login(USER, PASSWORD);
   String missingDir = "eleventy_squash";
   assertTrue(!session.changeWorkingDirectory(missingDir));
   assertTrue(!session.printWorkingDirectory().contains(missingDir));
 }
コード例 #2
0
 /**
  * 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")));
 }
コード例 #3
0
 /**
  * Tests restoring session after disconnect.
  *
  * @throws Exception
  */
 @Test
 public void test07CanRestoreSessionAfterDisconnect() throws Exception {
   session.disconnect();
   session.restore();
   assertTrue(session.isConnected());
   assertTrue(session.printWorkingDirectory().contains("for_testing"));
 }
コード例 #4
0
    /**
     * 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());
    }
コード例 #5
0
 /** Tests changing local directory. */
 @Test
 public void test03CanChangeLocalDirectory() {
   assertTrue(session.changeLocalDirectory(folder.getRoot().getPath()));
 }
コード例 #6
0
 /**
  * Tests login functionality.
  *
  * @throws Exception unexpected
  */
 @Test
 public void test02CanLogin() throws Exception {
   assertTrue(session.login(USER, PASSWORD));
   session.enterLocalPassiveMode();
   session.setFileType(FTP.BINARY_FILE_TYPE);
 }
コード例 #7
0
 /**
  * Tests connection functionality.
  *
  * @throws Exception unexpected
  */
 @Test
 public void test01CanConnect() throws Exception {
   session.connect(HOST, PORT);
   assertTrue(session.isConnected());
 }
コード例 #8
0
 @AfterClass
 public static void teardown() throws Exception {
   session.disconnect();
 }
コード例 #9
0
 /** Test attempt to login with bad credentials. */
 @Test
 public void test04LoginWithBadCredentialsFails() throws Exception {
   session.connect(HOST, PORT);
   assertTrue(!session.login("failtestuser", PASSWORD));
   assertTrue(!session.login(USER, "badpass"));
 }
コード例 #10
0
 /** Test attempt to login without a connection. */
 @Test(expected = IOException.class)
 public void test03LoginWithoutConnectThrowsException() throws Exception {
   session.login(USER, PASSWORD);
 }
コード例 #11
0
 /** Test handling of bad port. */
 @Test(expected = IOException.class)
 public void test02ConnectWithBadPortThrowsException() throws Exception {
   session.connect(HOST, 12345);
 }
コード例 #12
0
 /** Test handling of bad host. */
 @Test(expected = IOException.class)
 public void test01ConnectWithBadHostThrowsException() throws Exception {
   session.connect("banana", PORT);
 }
コード例 #13
0
 /**
  * Tests changing remote directory.
  *
  * @throws Exception
  */
 @Test
 public void test06CanChangeRemoteDirectory() throws Exception {
   assertTrue(session.changeWorkingDirectory("for_testing"));
   assertTrue(session.printWorkingDirectory().contains("for_testing"));
 }