Examples of CmdStor


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

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

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

      String fileName = "/production/resr_test_file.txt";
      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      byte[] data = getBytes("DATABYTES");

      CmdStor cmdStor = new CmdStor(fileName);
      cmdStor.setFileContent(data);

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

      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      CmdRetr cmdRetr = new CmdRetr(fileName);
      assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdRetr));

      byte[] dataAfter = cmdRetr.getFileContent();
      for (int i = 0; i < dataAfter.length; i++)
      {
         if (dataAfter[i] != data[i])
         {
            fail();
         }
      }

      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      assertEquals(FtpConst.Replyes.REPLY_350, client.executeCommand(new CmdRest(data.length)));

      byte[] secondData = getBytes("_APPENDED");

      cmdStor = new CmdStor(fileName);
      cmdStor.setFileContent(secondData);

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

      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      cmdRetr = new CmdRetr(fileName);
      assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdRetr));

      String secondString = "DATABYTES_APPENDED";

      byte[] secondDataAfter = cmdRetr.getFileContent();
      for (int i = 0; i < secondDataAfter.length; i++)
      {
         if (secondDataAfter[i] != (byte)secondString.charAt(i))
         {
            fail();
         }
      }

      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

      assertEquals(FtpConst.Replyes.REPLY_350, client.executeCommand(new CmdRest(4)));

      byte[] replasedData = getBytes("INT");

      cmdStor = new CmdStor(fileName);
      cmdStor.setFileContent(replasedData);

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

      assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));
View Full Code Here

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

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

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

                     assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(new CmdPasv()));

                     String file3 = folder2.substring(0);
                     file3 += "/test_file_" + i3 + ".txt";

                     CmdStor cmdStor = new CmdStor(file3);

                     byte[] fileData = new byte[256 * 4];
                     for (int c = 0; c < 256 * 4; c++)
                     {
                        fileData[c] = (byte)'A';
                        fileData[c] = fileData[c] += (byte)i3;
                     }

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

                     log.info("File [" + file3 + "] created");

                  }
View Full Code Here

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

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

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

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

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

      {
         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 - 125 Data connection already open; Transfer starting
      // 226 Transfer complete
View Full Code Here

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

         CmdPasv cmdPasv = new CmdPasv();
         assertEquals(FtpConst.Replyes.REPLY_227, client.executeCommand(cmdPasv));
      }

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

      {
         CmdSize cmdSize = new CmdSize(filePath);
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.