Package org.exoplatform.frameworks.ftpclient.client

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


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

      {
         FtpClientSession client = new FtpClientSessionImpl(FtpTestConfig.FTP_HOST, FtpTestConfig.FTP_PORT);
         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));
         }

         {
            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++)
            {

               String folderName = FtpTestConfig.TEST_FOLDER + "/" + i1;
               assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(new CmdMkd(folderName)));

               for (int i2 = 0; i2 < 10; i2++)
               {
                  String testSubFolder = folderName + "/" + i2;
                  assertEquals(FtpConst.Replyes.REPLY_257, client.executeCommand(new CmdMkd(testSubFolder)));
               }

            }
         }

         client.close();
      }

      HashMap<Integer, TestAgent> clients = new HashMap<Integer, TestAgent>();
      int count = 0;

      Random random = new Random();

      while (count < FtpTestConfig.CLIENTS_COUNT)
      {
         int nextId = random.nextInt(Integer.MAX_VALUE);
         log.info("NEXT ID: [" + nextId + "]");

         if (nextId < 10000)
         {
            continue;
         }

         Integer curInteger = new Integer(nextId);
         if (clients.containsKey(curInteger))
         {
            continue;
         }

         TestAgent testAgent = new TestAgent(curInteger, FtpTestConfig.CLIENT_DEPTH);
         clients.put(curInteger, testAgent);
         count++;
      }

      log.info("CLIENTS: [" + clients.size() + "]");

      Thread.sleep(3000);
      log.info("START ALL!!!!!!!!!!!!!!!!!!!!!!!!");
      IsNeedWaitAll = false;
      Thread.sleep(3000);

      {
         boolean alive = true;

         while (alive)
         {
            alive = false;
            Thread.sleep(2000);

            int live = 0;

            Iterator<Integer> keyIter = clients.keySet().iterator();
            while (keyIter.hasNext())
            {
               Integer agentKey = keyIter.next();
               TestAgent agent = clients.get(agentKey);
               if (agent.isAlive())
               {
                  alive = true;
                  live++;
               }
            }

            log.info(">>>>>>>>>>>>> LIVE: [" + live + "]");

         }
      }

      {
         {
            FtpClientSession client = new FtpClientSessionImpl(FtpTestConfig.FTP_HOST, FtpTestConfig.FTP_PORT);
            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));
            }

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

            assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdDele(FtpTestConfig.TEST_FOLDER)));
         }
      }

      {
         int successed = 0;
View Full Code Here


            while (MultiThreadCrushTest.IsNeedWaitAll)
            {
               Thread.sleep(1000);
            }

            client = new FtpClientSessionImpl(FtpTestConfig.FTP_HOST, FtpTestConfig.FTP_PORT);

            if (!client.connect(60))
            {
               return;
            }
View Full Code Here

   public static final String TEST_FOLDER = "/" + TEST_WORKSPACE + "/crash_test2";

   public static FtpClientSession getTestFtpClient()
   {
      return new FtpClientSessionImpl(FTP_HOST, FTP_PORT);
   }
View Full Code Here

      public void readAllFolders(String rootTestFolder)
      {
         try
         {
            FtpClientSession client = new FtpClientSessionImpl("127.0.0.1", 21);
            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_200, client.executeCommand(new CmdType("A")));

            for (int i1 = 1; i1 <= ITEMS_COUNT; i1++)
            {
               String folder1 = rootTestFolder + "/folder_" + i1;
               for (int i2 = 1; i2 <= ITEMS_COUNT; i2++)
               {
                  String folder2 = folder1.substring(0);
                  folder2 += "/subfolder_" + i2;
                  for (int i3 = 0; i3 < ITEMS_COUNT; i3++)
                  {
                     String file3 = folder2.substring(0);
                     file3 += "/test_file_" + i3 + ".txt";

                     log.info("CurFileName - [" + file3 + "]");

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

                     CmdRetr cmdRetr = new CmdRetr(file3);
                     int reply = client.executeCommand(cmdRetr);

                     log.info("RETR REPLY - " + reply);

                  }

               }

            }

            client.close();

         }
         catch (Exception exc)
         {
            log.info("Unhandled exception. " + exc.getMessage(), exc);
View Full Code Here

      public void removeAllFolders(String rootTestFolder)
      {
         log.info("Clearing...");
         try
         {
            FtpClientSession client = new FtpClientSessionImpl("127.0.0.1", 21);
            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_200, client.executeCommand(new CmdType("A")));

            for (int i1 = 1; i1 <= ITEMS_COUNT; i1++)
            {
               String folder1 = rootTestFolder + "/folder_" + i1;
               for (int i2 = 1; i2 <= ITEMS_COUNT; i2++)
               {
                  String folder2 = folder1.substring(0);
                  folder2 += "/subfolder_" + i2;
                  for (int i3 = 0; i3 < ITEMS_COUNT; i3++)
                  {
                     String file3 = folder2.substring(0);
                     file3 += "/test_file_" + i3 + ".txt";

                     log.info("Try delete [" + file3 + "]...");
                     assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdRmd(file3)));
                  }

                  log.info("Try delete [" + folder2 + "]...");
                  assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdRmd(folder2)));
               }

               log.info("Try delete [" + folder1 + "]...");
               assertEquals(FtpConst.Replyes.REPLY_250, client.executeCommand(new CmdRmd(folder1)));

            }

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

            client.close();
         }
         catch (Exception exc)
         {
            log.info("Unhandled exception. " + exc.getMessage(), exc);
         }
View Full Code Here

TOP

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

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.