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()));
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()));
cmdRetr = new CmdRetr(fileName);
assertEquals(FtpConst.Replyes.REPLY_226, client.executeCommand(cmdRetr));
String readyString = "DATAINTES_APPENDED";