Examples of FtpClientSession


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

   public void testPASV() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_PASV);
      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_227, client.executeCommand(new CmdPasv()));

      boolean connected = false;

      for (int i = 0; i < 15; i++)
      {
         try
         {
            if (client.getDataTransiver().isConnected())
            {
               connected = true;
               break;
            }
            Thread.sleep(1000);
         }
         catch (Exception exc)
         {
            log.info(FtpConst.EXC_MSG + exc.getMessage(), exc);
         }
      }

      assertEquals(true, connected);

      client.getDataTransiver().close();

      client.close();

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

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

   public void testPORT() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_PORT);
      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")));

      int MIN_PORT_VAL = 9000;
      int MAX_PORT_VAL = 10000;

      int ports = MAX_PORT_VAL - MIN_PORT_VAL + 1;

      Random random = new Random();

      String host = "127.0.0.1";
      int port = 0;

      boolean enableSearch = true;
      while (enableSearch)
      {
         port = MIN_PORT_VAL + random.nextInt(ports);
         if (FtpUtils.isPortFree(port))
         {
            enableSearch = false;
         }
      }

      FtpDataTransiver dataTransiver = new FtpDataTransiverImpl();
      dataTransiver.OpenActive(port);
      client.setDataTransiver(dataTransiver);

      try
      {
         Thread.sleep(1000);
      }
      catch (Exception exc)
      {
         log.info(FtpConst.EXC_MSG + exc.getMessage(), exc);
      }

      CmdPort cmdPort = new CmdPort(host, port);

      assertEquals(FtpConst.Replyes.REPLY_200, client.executeCommand(cmdPort));

      boolean connected = false;
      for (int i = 0; i < 15; i++)
      {
         try
         {
            if (client.getDataTransiver().isConnected())
            {
               connected = true;
               break;
            }
            Thread.sleep(1000);
         }
         catch (Exception exc)
         {
            log.info(FtpConst.EXC_MSG + exc.getMessage(), exc);
         }
      }

      assertEquals(true, connected);

      client.getDataTransiver().close();

      client.close();

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

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

   public void testLIST() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_LIST);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));
      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));
      assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(new CmdList()));

      client.close();

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

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

   public void testNLST() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_NLST);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("production")));
      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));
      assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(new CmdNlst()));

      client.close();

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

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

   public void testMKD() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_MKD);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(new CmdMkd("/production/test_folder")));

      client.close();

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

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

   public void testRMD() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_RMD);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(new CmdMkd("/production/test_folder")));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdRmd("/production/test_folder")));

      client.close();

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

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

   public void testRNFR_RNTO() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_RNFR + "_" + FtpConst.Commands.CMD_RNTO);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(new CmdMkd("/production/test_kokanoid_torename")));

      assertEquals(FtpConst.Replyes.REPLY_350, client.executeCommand(new CmdRnFr("/production/test_kokanoid_torename")));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdRnTo("/production/test_kokanoid_renamed")));
      assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdRmd("/production/test_kokanoid_renamed")));

      client.close();

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

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

   public void testSTOR() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_STOR);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      CmdStor cmdStor = new CmdStor("/production/test_file.txt");

      byte[] data = new byte[FILE_CONTENT.length()];
      char[] chars = FILE_CONTENT.toCharArray();
      for (int i = 0; i < data.length; i++)
      {
         data[i] = (byte)chars[i];
      }

      cmdStor.setFileContent(data);

      assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdStor));

      client.close();

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

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

   public void testSIZE() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_SIZE);
      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()));

      assertEquals(FtpConst.Replyes.REPLY_213, client.executeCommand(new CmdSize("/production/test_file.txt")));

      // retrieve size here..., assert it

      assertEquals(FtpConst.Replyes.REPLY_550, client.executeCommand(new CmdSize("/production/test_file_absent.txt")));

      client.close();

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

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

   public void testRETR() throws Exception
   {
      Log log = getLogger(FtpConst.Commands.CMD_RETR);
      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()));
      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      CmdRetr cmdRetr = new CmdRetr("/production/test_file.txt");
      assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdRetr));

      byte[] fileContent = cmdRetr.getFileContent();
      assertEquals(fileContent.length, FILE_CONTENT.length());

      for (int i = 0; i < fileContent.length; i++)
      {
         if (fileContent[i] != FILE_CONTENT.charAt(i))
         {
            fail();
         }
      }

      client.close();

      log.info("Complete.");
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.