
package org.apache.camel.component.file.remote;

import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.junit.Test;

public class FromFtpToMockTest extends FtpServerTestSupport {
    protected String expectedBody = "Hello there!";

    private String getFtpUrl() {
        return "ftp://admin@localhost:" + getPort() + "/tmp/camel?password=admin&recursive=true";
    }

    @Test
    public void testFtpRoute() throws Exception {
        MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
        resultEndpoint.expectedBodiesReceived(expectedBody);

        template.sendBodyAndHeader(getFtpUrl(), expectedBody, "cheese", 123);

        resultEndpoint.assertIsSatisfied();
    }

    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() throws Exception {
                from(getFtpUrl()).to("mock:result");
            }
        };
    }
}