add SshjSftp

This commit is contained in:
looly
2022-01-04 07:06:47 +08:00
parent a59c87b7d2
commit f572056d5a
3 changed files with 50 additions and 25 deletions

View File

@@ -1,8 +1,8 @@
package cn.hutool.extra.ftp;
package cn.hutool.extra.ssh;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.extra.ssh.SshjSftp;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
@@ -12,7 +12,6 @@ import java.util.List;
* 基于sshj 框架SFTP 封装测试.
*
* @author youyongkun
* @date 2021/12/31 16:11
* @since 5.7.18
*/
public class SftpTest {
@@ -20,11 +19,13 @@ public class SftpTest {
private SshjSftp sshjSftp;
@Before
@Ignore
public void init() {
sshjSftp = new SshjSftp("ip", 22, "test", "test", CharsetUtil.CHARSET_UTF_8);
}
@Test
@Ignore
public void lsTest() {
List<String> files = sshjSftp.ls("/");
if (files != null && !files.isEmpty()) {
@@ -33,28 +34,33 @@ public class SftpTest {
}
@Test
@Ignore
public void downloadTest() {
sshjSftp.recursiveDownloadFolder("/home/test/temp", new File("C:\\Users\\akwangl\\Downloads\\temp"));
}
@Test
@Ignore
public void uploadTest() {
sshjSftp.upload("/home/test/temp/", new File("C:\\Users\\akwangl\\Downloads\\temp\\辽宁_20190718_104324.CIME"));
}
@Test
@Ignore
public void mkDirTest() {
boolean flag = sshjSftp.mkdir("/home/test/temp");
System.out.println("是否创建成功: " + flag);
}
@Test
@Ignore
public void mkDirsTest() {
// 在当前目录下批量创建目录
sshjSftp.mkDirs("/home/test/temp");
}
@Test
@Ignore
public void delDirTest() {
sshjSftp.delDir("/home/test/temp");
}