📄 testftp.java
字号:
/*
* Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
* (license2)
* Initial Developer: H2 Group
*/
package org.h2.test.unit;
import org.h2.server.ftp.FtpEvent;
import org.h2.server.ftp.FtpEventListener;
import org.h2.server.ftp.FtpServer;
import org.h2.test.TestBase;
import org.h2.tools.Server;
/**
* Tests the FTP server tool.
*/
public class TestFtp extends TestBase implements FtpEventListener {
private FtpEvent lastEvent;
public void test() throws Exception {
test(baseDir);
}
private void test(String dir) throws Exception {
Server server = Server.createFtpServer(new String[]{"-ftpDir", dir, "-ftpPort", "8121"}).start();
FtpServer ftp = (FtpServer) server.getService();
ftp.setEventListener(this);
FtpClient client = FtpClient.open("localhost:8121");
client.login("sa", "sa");
client.makeDirectory("test");
client.changeWorkingDirectory("test");
check(lastEvent.getCommand(), "CWD");
client.makeDirectory("hello");
client.changeWorkingDirectory("hello");
client.changeDirectoryUp();
check(lastEvent.getCommand(), "CDUP");
client.nameList("hello");
client.removeDirectory("hello");
client.close();
server.stop();
}
public void beforeCommand(FtpEvent event) {
lastEvent = event;
}
public void afterCommand(FtpEvent event) {
lastEvent = event;
}
public void onUnsupportedCommand(FtpEvent event) {
lastEvent = event;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -