Search in sources :

Example 21 with Producer

use of org.apache.camel.Producer in project camel by apache.

the class FtpLoginTest method uploadFile.

private void uploadFile(String username, String password) throws Exception {
    Endpoint endpoint = context.getEndpoint("ftp://" + username + "@localhost:" + getPort() + "/login?password=" + password);
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World from FTPServer");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "report.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer)

Example 22 with Producer

use of org.apache.camel.Producer in project camel by apache.

the class FromFtpStartingDirAndFileNameClashTest method prepareFtpServer.

private void prepareFtpServer() throws Exception {
    // prepares the FTP Server by creating a file on the server that we want to unit
    // test that we can pool and store as a local file
    Endpoint endpoint = context.getEndpoint(getFtpUrl());
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "hello-world.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Producer(org.apache.camel.Producer)

Example 23 with Producer

use of org.apache.camel.Producer in project camel by apache.

the class FtpConsumerBodyAsStringTest method prepareFtpServer.

private void prepareFtpServer() throws Exception {
    // prepares the FTP Server by creating a file on the server that we want to unit
    // test that we can pool
    Endpoint endpoint = context.getEndpoint(getFtpUrl());
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Producer(org.apache.camel.Producer)

Example 24 with Producer

use of org.apache.camel.Producer in project camel by apache.

the class FromFtpToBinaryFilesTest method prepareFtpServer.

private void prepareFtpServer() throws Exception {
    // prepares the FTP Server by creating a file on the server that we want to unit
    // test that we can pool and store as a local file
    String ftpUrl = "ftp://admin@localhost:" + getPort() + "/incoming?password=admin&binary=true" + "&consumer.delay=2000&recursive=false";
    Endpoint endpoint = context.getEndpoint(ftpUrl);
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo.jpeg"));
    exchange.getIn().setHeader(Exchange.FILE_NAME, "logo.jpeg");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
    ftpUrl = "ftp://admin@localhost:" + getPort() + "/incoming/a?password=admin&binary=true" + "&consumer.delay=2000&recursive=false";
    endpoint = context.getEndpoint(ftpUrl);
    exchange = endpoint.createExchange();
    exchange.getIn().setBody(IOConverter.toFile("src/test/data/ftpbinarytest/logo1.jpeg"));
    exchange.getIn().setHeader(Exchange.FILE_NAME, "logo1.jpeg");
    producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Producer(org.apache.camel.Producer)

Example 25 with Producer

use of org.apache.camel.Producer in project camel by apache.

the class FromFtpToFileNoFileNameHeaderTest method prepareFtpServer.

private void prepareFtpServer() throws Exception {
    // prepares the FTP Server by creating a file on the server that we want to unit
    // test that we can pool and store as a local file
    Endpoint endpoint = context.getEndpoint(getFtpUrl());
    Exchange exchange = endpoint.createExchange();
    exchange.getIn().setBody("Hello World from FTPServer");
    exchange.getIn().setHeader(Exchange.FILE_NAME, "hello.txt");
    Producer producer = endpoint.createProducer();
    producer.start();
    producer.process(exchange);
    producer.stop();
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Producer(org.apache.camel.Producer)

Aggregations

Producer (org.apache.camel.Producer)197 Endpoint (org.apache.camel.Endpoint)139 Exchange (org.apache.camel.Exchange)138 Test (org.junit.Test)72 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)69 Processor (org.apache.camel.Processor)34 RouteBuilder (org.apache.camel.builder.RouteBuilder)23 Message (org.apache.camel.Message)21 CountDownLatch (java.util.concurrent.CountDownLatch)16 File (java.io.File)12 CamelContext (org.apache.camel.CamelContext)12 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)10 DefaultExchange (org.apache.camel.impl.DefaultExchange)9 Mockito.anyLong (org.mockito.Mockito.anyLong)9 Consumer (org.apache.camel.Consumer)8 FileDataSource (javax.activation.FileDataSource)7 AsyncProcessor (org.apache.camel.AsyncProcessor)7 DataHandler (javax.activation.DataHandler)6 Field (java.lang.reflect.Field)5 ExchangePattern (org.apache.camel.ExchangePattern)5