Examples of FtpClient


Examples of com.consol.citrus.ftp.client.FtpClient

        Map<String, FtpClient> clients = beanDefinitionContext.getBeansOfType(FtpClient.class);

        Assert.assertEquals(clients.size(), 4);

        // 1st ftp client
        FtpClient ftpClient = clients.get("ftpClient1");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getHost(), "localhost");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getPort(), new Integer(22222));
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getCorrelator().getClass(), DefaultMessageCorrelator.class);
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getTimeout(), 5000L);

        // 2nd ftp client
        ftpClient = clients.get("ftpClient2");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getHost(), "localhost");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getPort(), new Integer(22222));
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getCorrelator().getClass(), DefaultMessageCorrelator.class);
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getUser(), "user");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getPassword(), "consol");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getTimeout(), 10000L);

        // 3rd ftp client
        ftpClient = clients.get("ftpClient3");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getHost(), "localhost");
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getPort(), new Integer(22222));
        Assert.assertNotNull(ftpClient.getEndpointConfiguration().getCorrelator());
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getCorrelator(), beanDefinitionContext.getBean("replyMessageCorrelator"));

        // 4th ftp client
        ftpClient = clients.get("ftpClient4");
        Assert.assertNotNull(ftpClient.getActor());
        Assert.assertEquals(ftpClient.getActor(), beanDefinitionContext.getBean("testActor", TestActor.class));
        Assert.assertEquals(ftpClient.getEndpointConfiguration().getPollingInterval(), 250L);
    }
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

     *
     * @return          connected FTPClient
     * @throws Exception
     */
    public FTPClientInterface connect() throws Exception {
        FTPClient ftp = createClient();
        ftp.connect()
        ftp.login(user, password);
        return ftp;
    }
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

        return ftp;
    }
   
    private FTPClient createClient() throws Exception {
     // connect
        FTPClient ftp = null;
        if (!useDeprecatedConstructors) {
            ftp = new FTPClient();
            ftp.setRemoteHost(host);
            ftp.setTimeout(timeout);
           
        }
        else {
            ftp = new FTPClient(host, FTPControlSocket.CONTROL_PORT, timeout);
        }
        ftp.setAutoPassiveIPSubstitution(autoPassiveIPSubstitution);
        ftp.setConnectMode(connectMode);
        ftp.setDetectTransferMode(true);
        if (!strictReplies) {
            log.warn("Strict replies not enabled");
            ftp.setStrictReturnCodes(false);
        }
        return ftp;
    }
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

     *
     * @return          connected FTPClientInterface
     * @throws Exception
     */
    public FTPClientInterface connect(int lowest, int highest) throws Exception {
        FTPClient ftp = createClient();
        ftp.setActivePortRange(lowest, highest);
        ftp.connect()
        ftp.login(user, password);
        return ftp;
    }
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

        ftp.login(user, password);
        return ftp;
    }
   
    public void reconnect(FTPClientInterface ftp) throws Exception {
        FTPClient client = (FTPClient)ftp;
        client.connect();
        client.login(user, password);
    }
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

            String directory = args[4];
            String mode = args[5];
            String connMode = args[6];

            // connect and test supplying port no.
            FTPClient ftp = new FTPClient();
            ftp.setControlEncoding("UTF-8");
            ftp.setRemoteHost(host);
            ftp.setRemotePort(21);
            ftp.connect();
            ftp.login(user, password);
            ftp.quote("LANG da-DK", new String[] { "200" });
//            ftp.dirDetails(".");
            ftp.chdir("test");
            ftp.quit();
            if (true)
              return;

            // connect again
            ftp = new FTPClient();
            ftp.setRemoteHost(host);

            ftp.login(user, password);
           
            ftp.dir(".", false);

            // binary transfer
            if (mode.equalsIgnoreCase("BINARY")) {
                ftp.setType(FTPTransferType.BINARY);
            }
            else if (mode.equalsIgnoreCase("ASCII")) {
                ftp.setType(FTPTransferType.ASCII);
            }
            else {
                System.out.println("Unknown transfer type: " + args[5]);
                System.exit(-1);
            }

            // PASV or active?
            if (connMode.equalsIgnoreCase("PASV")) {
                ftp.setConnectMode(FTPConnectMode.PASV);
            }
            else if (connMode.equalsIgnoreCase("ACTIVE")) {
                ftp.setConnectMode(FTPConnectMode.ACTIVE);
            }
            else {
                System.out.println("Unknown connect mode: " + args[6]);
                System.exit(-1);
            }

            // change dir
            ftp.chdir(directory);

            // put a local file to remote host
            ftp.put(filename, filename);

            // get bytes
            byte[] buf = ftp.get(filename);
            System.out.println("Got " + buf.length + " bytes");

            // append local file
            try {
                ftp.put(filename, filename, true);
            }
            catch (FTPException ex) {
                System.out.println("Append failed: " + ex.getMessage());
            }

            // get bytes again - should be 2 x
            buf = ftp.get(filename);
            System.out.println("Got " + buf.length + " bytes");

            // rename
            ftp.rename(filename, filename + ".new");

            // get a remote file - the renamed one
            ftp.get(filename + ".tst", filename + ".new");

            // ASCII transfer
            ftp.setType(FTPTransferType.ASCII);

            // test that list() works
            String[] listing = ftp.dir(".");
            for (int i=0; i<listing.length; i++)
              System.out.println(listing[i]);

            // test that dir() works in full mode
            String[] listings = ftp.dir(".", true);
            for (int i = 0; i < listings.length; i++)
                System.out.println(listings[i]);

            // try system()
            System.out.println(ftp.system());

            // try pwd()
            System.out.println(ftp.pwd());

            ftp.quit();
        }
        catch (Exception ex) {
            System.out.println("Caught exception: " + ex.getMessage());
        }
    }
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

    bLoged = false;
    oFileSys = null;

    if (DebugFile.trace) DebugFile.writeln("new FTPClient(" + sHost + ")");

    oFTPC = new FTPClient(sHost);
    oFTPC.debugResponses(DebugFile.trace);

    if (DebugFile.trace) {
      oFW = new FileWriter("/tmp/javatrc.txt", true);
      oPW = new PrintWriter(oFW, true);
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

  private void copyFTPToFTP(String sSource, String sTarget)
    throws FTPException,IOException {

    String sSourceHost, sTargetHost, sSourcePath, sTargetPath, sSourceFile, sTargetFile, sTempName;
    FTPWorkerThread oReader,oWriter;
    FTPClient oFTPC;

    if (DebugFile.trace) {
      DebugFile.writeln("Begin FileSystem.copyFTPToFTP(" + sSource + "," + sTarget + ")");
      DebugFile.incIdent();
    }

    splitURI(sSource);
    sSourceHost = sHost;
    sSourcePath = sPath;
    if (!sSourcePath.endsWith("/")) sSourcePath+="/";
    sSourceFile = sFile;

    splitURI(sTarget);
    sTargetHost = sHost;
    sTargetPath = sPath;
    if (!sTargetPath.endsWith("/")) sTargetPath+="/";
    sTargetFile = sFile;

    if (sSourceHost.equals(sTargetHost) && (OS!=OS_PUREJAVA)) {
      sTempName = Gadgets.generateUUID();

      oFTPC = new FTPClient(sTargetHost);
      oFTPC.login(user(), password());

      if (DebugFile.trace)DebugFile.writeln("FTPClient.site(exec cp " + sSourcePath + sSourceFile + " " + sTargetPath + sTargetFile);
      oFTPC.rename(sSourcePath + sSourceFile, sSourcePath + sTempName );
      oFTPC.site("exec cp " + sSourcePath + sTempName + " " + sTargetPath + sTargetFile);
      oFTPC.rename(sSourcePath + sTempName, sSourcePath + sSourceFile);
      oFTPC.quit();
    }
    else {
      oReader = new FTPWorkerThread(sSourceHost, sUsr, sPwd);
      oWriter = new FTPWorkerThread(sTargetHost, sUsr, sPwd);
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

  // ---------------------------------------------------------------------------

  private void copyFileToFTP(String sSource, String sTarget) throws Exception,IOException {
    boolean bFTPSession = false;

    FTPClient oFTPC = null;

    splitURI(sTarget);

    try {
      if (DebugFile.trace) DebugFile.writeln("new FTPClient(" + sHost + ")");
      oFTPC = new FTPClient(sHost);
      if (DebugFile.trace) DebugFile.writeln("FTPClient.login(" + sUsr + "," + sPwd + ")");
      oFTPC.login(sUsr, sPwd);
      bFTPSession = true;
      if (DebugFile.trace) DebugFile.writeln("FTPClient.chdir(" + sPath + ")");
      oFTPC.chdir(sPath);
      if (DebugFile.trace) DebugFile.writeln("FTPClient.put(" + sSource + "," + sFile + ",false)");
      oFTPC.setType(FTPTransferType.BINARY);
      oFTPC.put(sSource, sFile, false);

    } catch (FTPException ftpe) {
      throw new Exception(ftpe.getMessage(), ftpe.getCause());
    }
    finally {
      if (DebugFile.trace) DebugFile.writeln("FTPClient.quit()");
      if (bFTPSession) oFTPC.quit();
    }

  } // copyFileToFTP()
View Full Code Here

Examples of com.enterprisedt.net.ftp.FTPClient

  private void copyFTPToFile(String sSource, String sTarget)
    throws Exception,IOException {

    boolean bFTPSession = false;

    FTPClient oFTPC = null;

    splitURI(sSource);

    try {
      if (DebugFile.trace) DebugFile.writeln("new FTPClient(" + sHost + ")");
      oFTPC = new FTPClient(sHost);
      if (DebugFile.trace) DebugFile.writeln("FTPClient.login(" + sUsr + "," + sPwd + ")");
      oFTPC.login(sUsr, sPwd);
      bFTPSession = true;
      if (DebugFile.trace) DebugFile.writeln("FTPClient.chdir(" + sPath + ")");
      oFTPC.chdir(sPath);
      if (DebugFile.trace) DebugFile.writeln("FTPClient.get(" + sTarget + "," + sFile + ",false)");
      oFTPC.setType(FTPTransferType.BINARY);
      oFTPC.get(sTarget, sFile);

    } catch (FTPException ftpe) {
      throw new Exception(ftpe.getMessage(), ftpe.getCause());
    }
    finally {
      if (DebugFile.trace) DebugFile.writeln("FTPClient.quit()");
      if (bFTPSession) oFTPC.quit();
    }

  } // copyFileToFTP()
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.