83 lines
2.4 KiB
Java
83 lines
2.4 KiB
Java
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/ftp/cms/";
|
||
|
||
@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,"新名称.doc");
|
||
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);
|
||
}
|
||
}
|
||
} |