Examples of FtpMessage


Examples of com.consol.citrus.ftp.message.FtpMessage

        expect(ftpRequest.getArgument()).andReturn("testDir").once();

        expect(endpointAdapter.handleMessage(anyObject(FtpMessage.class))).andAnswer(new IAnswer<FtpMessage>() {
            @Override
            public FtpMessage answer() throws Throwable {
                FtpMessage ftpMessage = (FtpMessage) getCurrentArguments()[0];

                Assert.assertEquals(ftpMessage.getPayload(String.class), FTPCmd.MKD.getCommand());

                Assert.assertEquals(ftpMessage.getCommand(), FTPCmd.MKD);
                Assert.assertEquals(ftpMessage.getArguments(), "testDir");
                Assert.assertNull(ftpMessage.getReplyCode());
                Assert.assertNull(ftpMessage.getReplyString());

                return new FtpMessage(FTPCmd.MKD, "testDir").setReplyCode(200). setReplyString("OK");
            }
        });

        replay(endpointAdapter, ftpSession, ftpRequest);
View Full Code Here

Examples of com.consol.citrus.ftp.message.FtpMessage

        expect(apacheFtpClient.sendCommand(FTPCmd.PWD, null)).andReturn(200).once();

        replay(apacheFtpClient);

        ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context);

        Message reply = ftpClient.receive(context);

        Assert.assertTrue(reply instanceof FtpMessage);

        FtpMessage ftpReply = (FtpMessage) reply;

        Assert.assertEquals(ftpReply.getCommand(), FTPCmd.PWD);
        Assert.assertNull(ftpReply.getArguments());
        Assert.assertEquals(ftpReply.getReplyCode(), new Integer(200));
        Assert.assertEquals(ftpReply.getReplyString(), "OK");

        verify(apacheFtpClient);
    }
View Full Code Here

Examples of com.consol.citrus.ftp.message.FtpMessage

        expect(apacheFtpClient.sendCommand(FTPCmd.PWD, null)).andReturn(200).once();
        expect(apacheFtpClient.sendCommand(FTPCmd.MKD, "testDir")).andReturn(201).once();

        replay(apacheFtpClient);

        ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context);

        Message reply = ftpClient.receive(context);

        Assert.assertTrue(reply instanceof FtpMessage);

        FtpMessage ftpReply = (FtpMessage) reply;

        Assert.assertEquals(ftpReply.getCommand(), FTPCmd.PWD);
        Assert.assertNull(ftpReply.getArguments());
        Assert.assertEquals(ftpReply.getReplyCode(), new Integer(200));
        Assert.assertEquals(ftpReply.getReplyString(), "OK");

        ftpClient.send(new FtpMessage(FTPCmd.MKD, "testDir"), context);

        reply = ftpClient.receive(context);

        Assert.assertTrue(reply instanceof FtpMessage);

        ftpReply = (FtpMessage) reply;

        Assert.assertEquals(ftpReply.getCommand(), FTPCmd.MKD);
        Assert.assertEquals(ftpReply.getArguments(), "testDir");
        Assert.assertEquals(ftpReply.getReplyCode(), new Integer(201));
        Assert.assertEquals(ftpReply.getReplyString(), "OK");

        verify(apacheFtpClient);
    }
View Full Code Here

Examples of com.consol.citrus.ftp.message.FtpMessage

        expect(apacheFtpClient.login("admin", "consol")).andReturn(false).once();

        replay(apacheFtpClient);

        ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context);

        verify(apacheFtpClient);
    }
View Full Code Here

Examples of com.consol.citrus.ftp.message.FtpMessage

        expect(apacheFtpClient.sendCommand(FTPCmd.PWD, null)).andReturn(500).once();

        replay(apacheFtpClient);

        ftpClient.send(new FtpMessage(FTPCmd.PWD, null), context);

        verify(apacheFtpClient);
    }
View Full Code Here

Examples of com.consol.citrus.ftp.message.FtpMessage

        return (FtpEndpointConfiguration) super.getEndpointConfiguration();
    }

    @Override
    public void send(Message message, TestContext context) {
        FtpMessage ftpMessage;
        if (message instanceof FtpMessage) {
            ftpMessage = (FtpMessage) message;
        } else {
            ftpMessage = new FtpMessage(message);
        }

        String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(ftpMessage);
        context.saveCorrelationKey(correlationKey, this);

        log.info(String.format("Sending FTP message to: ftp://'%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()));

        if (log.isDebugEnabled()) {
            log.debug("Message to be sent:\n" + ftpMessage.getPayload().toString());
        }

        try {
            connectAndLogin();

            int reply = ftpClient.sendCommand(ftpMessage.getCommand(), ftpMessage.getArguments());

            if(!FTPReply.isPositiveCompletion(reply) && !FTPReply.isPositivePreliminary(reply)) {
                throw new CitrusRuntimeException(String.format("Failed to send FTP command - reply is: %s:%s", reply, ftpClient.getReplyString()));
            }

            log.info(String.format("FTP message was successfully sent to: '%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()));

            onReplyMessage(correlationKey, new FtpMessage(ftpMessage.getCommand(), ftpMessage.getArguments())
                                                        .setReplyCode(reply)
                                                        .setReplyString(ftpClient.getReplyString()));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to execute ftp command", e);
        }
View Full Code Here

Examples of com.consol.citrus.ftp.message.FtpMessage

    public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException, IOException {
        String command = request.getCommand().toUpperCase();

        log.info(String.format("Received FTP command: '%s'", command));

        endpointAdapter.handleMessage(new FtpMessage(FTPCmd.valueOf(command), request.getArgument()));

        return FtpletResult.DEFAULT;
    }
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.