Package org.exoplatform.frameworks.ftpclient.client

Examples of org.exoplatform.frameworks.ftpclient.client.FtpClientSession


   public void testPASS() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_PASS);
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser("admin")));
      assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass("admin")));

      client.close();

      log.info("Complete.");
   }
View Full Code Here


   public void testSYST() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_SYST);
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser("admin")));
      assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass("admin")));
      assertEquals(FtpConst.Replyes.REPLY_215, client.executeCommand(new CmdSyst()));

      log.info("Complete.");
   }
View Full Code Here

   public void testPWD() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_PWD);
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser("admin")));
      assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass("admin")));

      CmdPwd cmdPwd = new CmdPwd();
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdPwd));

      log.info("CURRENTPATH - [" + cmdPwd.getCurrentPath() + "]");

      // assertEquals("/", cmdPwd.getCurrentPath());
View Full Code Here

      Log log = getLogger(FtpConst.Commands.CMD_CWD);
      log.info("Test...");

      // success

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser("admin")));
      assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass("admin")));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));

      CmdPwd cmdPwd = new CmdPwd();
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdPwd));
      assertEquals("/production", cmdPwd.getCurrentPath());

      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("../backup/")));

      cmdPwd = new CmdPwd();

      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdPwd));
      assertEquals("/backup", cmdPwd.getCurrentPath());

      assertEquals(FtpConst.Replyes.REPLY_550, client.executeCommand(new CmdCwd("production")));

      client.close();

      // denied
      client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_530, client.executeCommand(new CmdCwd("production")));

      client.close();

      log.info("Complete.");
   }
View Full Code Here

   public void testCDUP() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_CDUP);
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser("admin")));
      assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass("admin")));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));

      CmdPwd cmdPwd = new CmdPwd();
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdPwd));
      assertEquals("/production", cmdPwd.getCurrentPath());

      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCdUp()));

      cmdPwd = new CmdPwd();
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdPwd));
      assertEquals("/", cmdPwd.getCurrentPath());

      client.close();

      log.info("Complete.");
   }
View Full Code Here

   public void testTYPE() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_TYPE);
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser("admin")));
      assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass("admin")));

      assertEquals(FtpConst.Replyes.REPLY_200, client.executeCommand(new CmdType("A")));
      assertEquals(FtpConst.Replyes.REPLY_200, client.executeCommand(new CmdType("I")));
      assertEquals(FtpConst.Replyes.REPLY_500, client.executeCommand(new CmdType("SOMETYPE")));

      client.close();

      log.info("Complete.");
   }
View Full Code Here

   }
  
   public void testForbiddenCharsMKD() throws Exception {
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      {
        CmdUser cmdUser = new CmdUser(FtpTestConfig.USER_ID);
        assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(cmdUser));
      }

      {
        CmdPass cmdPass = new CmdPass(FtpTestConfig.USER_PASS);
        assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(cmdPass));
      }

      {
        CmdCwd cmdCwd = new CmdCwd("production");
        assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdCwd));

        String folderName = "test_folder_123" + ":[]*'\"|" + "123";

        CmdMkd cmdMkd = new CmdMkd(folderName);
        assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdMkd));
       
        CmdRmd cmdRmd = new CmdRmd("test_folder_123" + "_______" + "123");
        assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdRmd));
      }

      client.close();
      log.info("Complete.\r\n");
    }
View Full Code Here

   public void testSTOR() throws Exception
   {
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      byte[] fileContent = "THIS FILE CONTENT".getBytes();

      // desired reply - 530 Please login with USER and PASS
      {
         CmdStor cmdStor = new CmdStor(null);
         cmdStor.setFileContent(fileContent);
         assertEquals(FtpConst.Replyes.REPLY_530, client.executeCommand(cmdStor));
      }

      // login
      {
         assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(new CmdUser(FtpTestConfig.USER_ID)));
         assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(new CmdPass(FtpTestConfig.USER_PASS)));
      }

      // desired reply - 425 Unable to build data connection
      {
         CmdStor cmdStor = new CmdStor(null);
         cmdStor.setFileContent(fileContent);
         assertEquals(FtpConst.Replyes.REPLY_425, client.executeCommand(cmdStor));
      }

      // desired reply - 500 STOR: command requires a parameter
      {
         assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

         CmdStor cmdStor = new CmdStor(null);
         cmdStor.setFileContent(fileContent);
         assertEquals(FtpConst.Replyes.REPLY_500, client.executeCommand(cmdStor));
      }

      String fileName = "test_stor_file_" + System.currentTimeMillis() + ".txt";

      // desired reply - 550 test_stor_file.txt: Permission denied
      {
         assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

         CmdStor cmdStor = new CmdStor(fileName);
         cmdStor.setFileContent(fileContent);
         assertEquals(FtpConst.Replyes.REPLY_550, client.executeCommand(cmdStor));
      }

      // desired reply - 125 Data connection already open; Transfer starting
      // 226 Transfer complete
      {
         assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));
         assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

         CmdStor cmdStor = new CmdStor(fileName);
         cmdStor.setFileContent(fileContent);
         assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdStor));
      }

      // desired reply - 550 Restore value invalid
      {
         assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));
         assertEquals(FtpConst.Replyes.REPLY_350, client.executeCommand(new CmdRest(1000)));

         CmdStor cmdStor = new CmdStor(fileName);
         cmdStor.setFileContent(fileContent);
         assertEquals(FtpConst.Replyes.REPLY_550, client.executeCommand(cmdStor));
      }

      {
         assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdDele(fileName)));
      }

      client.close();
      log.info("Complete.\r\n");
   }
View Full Code Here

   }
  
   public void testForbiddenChars_STOR() throws Exception {
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      byte[] fileContent = "THIS FILE CONTENT".getBytes();

      // login
      {
        assertEquals(FtpConst.Replyes.REPLY_331,
                     client.executeCommand(new CmdUser(FtpTestConfig.USER_ID)));
        assertEquals(FtpConst.Replyes.REPLY_230,
                     client.executeCommand(new CmdPass(FtpTestConfig.USER_PASS)));
      }

      String fileName = "test_stor_file_" + ":[]*'\"|" + ".txt";

      // desired reply - 125 Data connection already open; Transfer starting
      // 226 Transfer complete
      {
        assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));
        assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

        CmdStor cmdStor = new CmdStor(fileName);
        cmdStor.setFileContent(fileContent);
        assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdStor));
      }

      {
        assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdDele("test_stor_file_" + "_______" + ".txt")));
      }

      client.close();
      log.info("Complete.\r\n");
    }
View Full Code Here

   public void testPWD() throws Exception
   {
      log.info("Test...");

      FtpClientSession client = FtpTestConfig.getTestFtpClient();
      client.connect();

      {
         CmdPwd cmdPwd = new CmdPwd();
         assertEquals(FtpConst.Replyes.REPLY_530, client.executeCommand(cmdPwd));
      }

      {
         CmdUser cmdUser = new CmdUser(FtpTestConfig.USER_ID);
         assertEquals(FtpConst.Replyes.REPLY_331, client.executeCommand(cmdUser));
      }

      {
         CmdPass cmdPass = new CmdPass(FtpTestConfig.USER_PASS);
         assertEquals(FtpConst.Replyes.REPLY_230, client.executeCommand(cmdPass));
      }

      {
         CmdPwd cmdPwd = new CmdPwd();
         assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdPwd));
      }

      client.close();
      log.info("Complete.\r\n");
   }
View Full Code Here

TOP

Related Classes of org.exoplatform.frameworks.ftpclient.client.FtpClientSession

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.