use of org.springframework.integration.samples.ftp.support.TestUserManager in project spring-integration-samples by spring-projects.
the class TestSuite method setupFtpServer.
@BeforeClass
public static void setupFtpServer() throws FtpException, IOException {
Integer availableServerSocket;
if (System.getProperty(SERVER_PORT_SYSTEM_PROPERTY) == null) {
availableServerSocket = 0;
} else {
availableServerSocket = Integer.valueOf(System.getProperty(SERVER_PORT_SYSTEM_PROPERTY));
}
File ftpRoot = new File(FTP_ROOT_DIR);
ftpRoot.mkdirs();
TestUserManager userManager = new TestUserManager(ftpRoot.getAbsolutePath());
FtpServerFactory serverFactory = new FtpServerFactory();
serverFactory.setUserManager(userManager);
ListenerFactory factory = new ListenerFactory();
factory.setPort(availableServerSocket);
factory.setIdleTimeout(600);
serverFactory.addListener("default", factory.createListener());
server = serverFactory.createServer();
server.start();
Listener listener = serverFactory.getListeners().values().iterator().next();
availableServerSocket = listener.getPort();
LOGGER.info("Using open server port..." + availableServerSocket);
System.setProperty(SERVER_PORT_SYSTEM_PROPERTY, availableServerSocket.toString());
}
Aggregations