Ejemplo n.º 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));
 }
Ejemplo n.º 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")));
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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());
    }
Ejemplo n.º 5
0
 /** Tests changing local directory. */
 @Test
 public void test03CanChangeLocalDirectory() {
   assertTrue(session.changeLocalDirectory(folder.getRoot().getPath()));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 7
0
 /**
  * Tests connection functionality.
  *
  * @throws Exception unexpected
  */
 @Test
 public void test01CanConnect() throws Exception {
   session.connect(HOST, PORT);
   assertTrue(session.isConnected());
 }
Ejemplo n.º 8
0
 @AfterClass
 public static void teardown() throws Exception {
   session.disconnect();
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 10
0
 /** Test attempt to login without a connection. */
 @Test(expected = IOException.class)
 public void test03LoginWithoutConnectThrowsException() throws Exception {
   session.login(USER, PASSWORD);
 }
Ejemplo n.º 11
0
 /** Test handling of bad port. */
 @Test(expected = IOException.class)
 public void test02ConnectWithBadPortThrowsException() throws Exception {
   session.connect(HOST, 12345);
 }
Ejemplo n.º 12
0
 /** Test handling of bad host. */
 @Test(expected = IOException.class)
 public void test01ConnectWithBadHostThrowsException() throws Exception {
   session.connect("banana", PORT);
 }
Ejemplo n.º 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"));
 }