测试嵌入式Mina FTPServer是否真正启动
我以编程方式编写了 apache 服务器的启动代码,如下所示:
public void _start()
{
String Path = "C:\\Dokumente und Einstellungen\\andjock\\Desktop\\ab";
File ftpDirectory = new File(Path);
ftpDirectory.mkdirs();
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory factory = new ListenerFactory();
factory.setPort(2221);
try {
serverFactory.addListener("default", factory.createListener());
PropertiesUserManagerFactory userFactory = new PropertiesUserManagerFactory();
File userFile = new File("C:\\Dokumente und Einstellungen\\andjock\\Desktop\\ftpusers.properties");
userFactory.setFile(userFile);
UserManager um = userFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("myNewUser");
user.setPassword("secret");
user.setHomeDirectory(Path);
um.save(user);
serverFactory.setUserManager(um);
FtpServer ftpServer = serverFactory.createServer();
ftpServer.start();
} catch (Exception e) {
Logger LOGGER = Logger.getLogger(TestapacheFtpServer.class);
LOGGER.log(Level.FATAL, "Unable to start test ftpserver", e);
}
我如何知道服务器是否真正工作?
我如何从“外部”访问这个 apache 服务器?
我尝试在我的机器上使用 telnet 和 ftp (ftp 127.0.0.1),但我收到:
FTP:连接:未知错误代码
有人知道吗?我只是不想依赖 jvm 日志,而是测试它,并访问启动它
i wrote programmatically a startup code of the apache Server like this:
public void _start()
{
String Path = "C:\\Dokumente und Einstellungen\\andjock\\Desktop\\ab";
File ftpDirectory = new File(Path);
ftpDirectory.mkdirs();
FtpServerFactory serverFactory = new FtpServerFactory();
ListenerFactory factory = new ListenerFactory();
factory.setPort(2221);
try {
serverFactory.addListener("default", factory.createListener());
PropertiesUserManagerFactory userFactory = new PropertiesUserManagerFactory();
File userFile = new File("C:\\Dokumente und Einstellungen\\andjock\\Desktop\\ftpusers.properties");
userFactory.setFile(userFile);
UserManager um = userFactory.createUserManager();
BaseUser user = new BaseUser();
user.setName("myNewUser");
user.setPassword("secret");
user.setHomeDirectory(Path);
um.save(user);
serverFactory.setUserManager(um);
FtpServer ftpServer = serverFactory.createServer();
ftpServer.start();
} catch (Exception e) {
Logger LOGGER = Logger.getLogger(TestapacheFtpServer.class);
LOGGER.log(Level.FATAL, "Unable to start test ftpserver", e);
}
How do i know that the server is really working ?
how can i access this apache Server , from the "outside"?
i tried with a telnet and ftp (ftp 127.0.0.1) on my machine but i received:
FTP: connect : unknown error code
does someone got any idea ? i just don't want to rely on the jvm log, but rather test it , and accesing the started it
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白了!我使用 FTP 客户端库(apache commons 库)编写了一个客户端来测试连接并列出文件;类似的东西
i figure it out!! i wrote a client using the FTP client library (the apache commons library) to test connectivity and list the files ; something like that