}
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);
{