FTP下载,本地测试通过
This commit is contained in:
83
src/test/java/com/fjy/spring/untils/FtpUtilsTest.java
Normal file
83
src/test/java/com/fjy/spring/untils/FtpUtilsTest.java
Normal file
@@ -0,0 +1,83 @@
|
||||
package com.fjy.spring.untils;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class FtpUtilsTest {
|
||||
private static final String destName = "ERP实验1:销售预测与SOP.doc";
|
||||
private static final String directory = "/www/cmsftp/";
|
||||
|
||||
@Test
|
||||
public void upload() throws Exception{
|
||||
String srcFileName = "F:\\JAVA Workspace\\Temp\\upload\\ERP实验1:销售预测与SOP.doc";
|
||||
FtpUtils.upload(directory,srcFileName,destName);
|
||||
list();
|
||||
}
|
||||
|
||||
/**
|
||||
* WIN10下载文件为0kb,请勿使用
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void download() throws Exception{
|
||||
String downloadName = "F:\\JAVA Workspace\\Temp\\ERP实验1:销售预测与SOP.doc";
|
||||
|
||||
FtpUtils.download(directory,destName,downloadName);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void downFtpFile() throws Exception{
|
||||
String downloadName = "F:\\JAVA Workspace\\Temp\\";
|
||||
boolean res = FtpUtils.downFtpFile(directory,destName,downloadName);
|
||||
System.out.println(res);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rename() throws Exception{
|
||||
String oldFileName = destName;
|
||||
String newFileName = "新名称.doc";
|
||||
FtpUtils.rename(directory,oldFileName, newFileName);
|
||||
list();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void remove() throws Exception{
|
||||
FtpUtils.remove(directory,destName);
|
||||
list();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void makeDirecotory() throws Exception{
|
||||
String newDirectory = "test";
|
||||
String newDirectoryZH = "新目录";
|
||||
FtpUtils.makeDirecotory(directory,newDirectory);
|
||||
FtpUtils.makeDirecotory(directory,newDirectoryZH);
|
||||
list();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renameDirecotory() throws Exception{
|
||||
String oldDirectoryZH = "新目录";
|
||||
String newDirectoryZH = "重命名目录";
|
||||
FtpUtils.renameDirecotory(directory,oldDirectoryZH,newDirectoryZH);
|
||||
list();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeDirecotory() throws Exception{
|
||||
String newDirectory = "test";
|
||||
String newDirectoryZH = "重命名目录";
|
||||
FtpUtils.removeDirecotory(directory,newDirectory);
|
||||
FtpUtils.removeDirecotory(directory,newDirectoryZH);
|
||||
list();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void list() throws Exception{
|
||||
String[] lists = FtpUtils.list(directory);
|
||||
for (String list : lists){
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user