Package org.exoplatform.frameworks.ftpclient.commands

Examples of org.exoplatform.frameworks.ftpclient.commands.CmdCwd


      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


      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());
View Full Code Here

      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();
View Full Code Here

      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();
View Full Code Here

            CmdSyst cmdSyst = new CmdSyst();
            assertEquals(FtpConst.Replyes.REPLY_215, client.executeCommand(cmdSyst));
         }

         {
            CmdCwd cmdCwd = new CmdCwd(FtpTestConfig.TEST_FOLDER);
            if (FtpConst.Replyes.REPLY_550 == client.executeCommand(cmdCwd))
            {
               CmdMkd cmdMkd = new CmdMkd(FtpTestConfig.TEST_FOLDER);
               assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdMkd));

               cmdCwd = new CmdCwd(FtpTestConfig.TEST_FOLDER);
               assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdCwd));
            }

            for (int i1 = 0; i1 < 10; i1++)
            {
View Full Code Here

            }

            Thread.sleep(SLEEP);

            {
               CmdCwd cmdCwd = new CmdCwd(FtpTestConfig.TEST_FOLDER);
               assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(cmdCwd));
            }

            Thread.sleep(SLEEP);

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

            Thread.sleep(SLEEP);

            String folderName = "" + agentId;

            String folder1Name = folderName.substring(0, 1);
            log.info("FOLDER 1 NAME: [" + folder1Name + "]");

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

            Thread.sleep(SLEEP);

            String folder2Name = folderName.substring(1, 2);

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

            Thread.sleep(SLEEP);

            {
               CmdMkd cmdMkd = new CmdMkd(folderName);
               assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdMkd, FtpConst.Replyes.REPLY_257, 3));
            }

            Thread.sleep(SLEEP);

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

            Thread.sleep(SLEEP);

            String folderPath = FtpTestConfig.TEST_FOLDER + "/" + folder1Name + "/" + folder2Name + "/" + folderName;
            log.info("FOLDER PATH: [" + folderPath + "]");

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

            Thread.sleep(SLEEP);

            for (int i1 = 0; i1 < itemsCount; i1++)
            {

               String tf1Name = "test_folder_" + i1;

               CmdMkd cmdMkd = new CmdMkd(tf1Name);
               assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(cmdMkd, FtpConst.Replyes.REPLY_257, 3));

               Thread.sleep(SLEEP);

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

               Thread.sleep(SLEEP);

               for (int i2 = 0; i2 < itemsCount; i2++)
               {
                  String tf2Name = "test_file_" + i2;

                  int expectReply = 3;
                  while (expectReply > 0)
                  {

                     int pasvReply = client.executeCommand(new CmdPasv(), FtpConst.Replyes.REPLY_227, 3);
                     if (pasvReply == FtpConst.Replyes.REPLY_227)
                     {
                        // byte []data = ("TEST FILE CONTENT " + i2).getBytes();
                        byte[] data = new byte[20 * 1024];

                        CmdStor cmdStor = new CmdStor(tf2Name);
                        cmdStor.setFileContent(data);
                        int storReply = client.executeCommand(cmdStor);
                        if (storReply == FtpConst.Replyes.REPLY_226)
                        {
                           break;
                        }
                        Thread.sleep(SLEEP);
                     }

                     Thread.sleep(SLEEP);
                     expectReply--;
                  }

                  if (expectReply == 0)
                  {
                     fail();
                  }
               }

               assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("..")));
               Thread.sleep(SLEEP);
            }

            for (int i1 = 0; i1 < itemsCount; i1++)
            {

               String tf1Name = "test_folder_" + i1;

               assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd(tf1Name)));
               Thread.sleep(SLEEP);

               for (int i2 = 0; i2 < itemsCount; i2++)
               {
                  String tf2Name = "test_file_" + i2;

                  int expectReply = 3;
                  while (expectReply > 0)
                  {
                     int pasvReply = client.executeCommand(new CmdPasv(), FtpConst.Replyes.REPLY_227, 3);
                     if (pasvReply == FtpConst.Replyes.REPLY_227)
                     {
                        CmdRetr cmdRetr = new CmdRetr(tf2Name);
                        int retrReply = client.executeCommand(cmdRetr);
                        if (retrReply == FtpConst.Replyes.REPLY_226)
                        {
                           break;
                        }
                     }
                  }

                  if (expectReply == 0)
                  {
                     fail();
                  }

                  Thread.sleep(SLEEP);
               }

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

            Thread.sleep(SLEEP);

            {
               assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdCwd("..")));
            }

            Thread.sleep(SLEEP);

            {
View Full Code Here

         CmdMkd cmdMkd = new CmdMkd("myfolder");
         assertEquals(FtpConst.Replyes.REPLY_550, client.executeCommand(cmdMkd));
      }

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

         String folderName = "test_folder_" + System.currentTimeMillis();

         CmdMkd cmdMkd = new CmdMkd(folderName);
View Full Code Here

        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);
View Full Code Here

      }

      // 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));
View Full Code Here

      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));
View Full Code Here

TOP

Related Classes of org.exoplatform.frameworks.ftpclient.commands.CmdCwd

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.