modules/tests/test-integration/src/test/java/org/ballerinalang/test/util/FTPTestServer.java
public void start() throws FtpException, IOException {
        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        UserManager userManager = userManagerFactory.createUserManager();
        BaseUser user = new BaseUser();
        user.setName("username");
        user.setPassword("password");
        ClassLoader classLoader = getClass().getClassLoader();
        String fileURI = new File(classLoader.getResource(Constant.VFS_LOCATION).getFile()).getAbsolutePath();
        List<Authority> authorities = new ArrayList<Authority>();
        authorities.add(new WritePermission());
        user.setAuthorities(authorities);
        user.setHomeDirectory(fileURI);
        userManager.save(user);

        ListenerFactory listenerFactory = new ListenerFactory();
        listenerFactory.setPort(2221);

        FtpServerFactory factory = new FtpServerFactory();
        factory.setUserManager(userManager);
        factory.addListener("default", listenerFactory.createListener());

        if (ftpServer == null) {
            ftpServer = factory.createServer();
            ftpServer.start();
        }
    }
/**
     * To start the FTP server.
     * @throws FtpException FTP Exception
     * @throws IOException IO Exception
     */
To start the FTP server.
@throws FtpException FTP Exception
@throws IOException IO Exception
To start the FTP server . @throws FtpException FTP Exception @throws IOException IO Exception
public void start() throws FtpException, IOException {
        PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
        UserManager userManager = userManagerFactory.createUserManager();
        BaseUser user = new BaseUser();
        user.setName("username");
        user.setPassword("password");
        ClassLoader classLoader = getClass().getClassLoader();
        String fileURI = new File(classLoader.getResource(Constant.VFS_LOCATION).getFile()).getAbsolutePath();
        List<Authority> authorities = new ArrayList<Authority>();
        authorities.add(new WritePermission());
        user.setAuthorities(authorities);
        user.setHomeDirectory(fileURI);
        userManager.save(user);
        ListenerFactory listenerFactory = new ListenerFactory();
        listenerFactory.setPort(2221);
        FtpServerFactory factory = new FtpServerFactory();
        factory.setUserManager(userManager);
        factory.addListener("default", listenerFactory.createListener());
        if (ftpServer == null) {
            ftpServer = factory.createServer();
            ftpServer.start();
        }
    }
public void start ( ) throws FtpException , IOException { PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory ( ) ; UserManager userManager = userManagerFactory . createUserManager ( ) ; BaseUser user = new BaseUser ( ) ; user . setName ( "username" ) ; user . setPassword ( "password" ) ; ClassLoader classLoader = getClass ( ) . getClassLoader ( ) ; String fileURI = new File ( classLoader . getResource ( Constant . VFS_LOCATION ) . getFile ( ) ) . getAbsolutePath ( ) ; List < Authority > authorities = new ArrayList < Authority > ( ) ; authorities . add ( new WritePermission ( ) ) ; user . setAuthorities ( authorities ) ; user . setHomeDirectory ( fileURI ) ; userManager . save ( user ) ; ListenerFactory listenerFactory = new ListenerFactory ( ) ; listenerFactory . setPort ( 2221 ) ; FtpServerFactory factory = new FtpServerFactory ( ) ; factory . setUserManager ( userManager ) ; factory . addListener ( "default" , listenerFactory . createListener ( ) ) ; if ( ftpServer == null ) { ftpServer = factory . createServer ( ) ; ftpServer . start ( ) ; } }
To start the FTP server.
To start the FTP server .