Search in sources :

Example 1 with Producer

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

the class CMISQueryProducerTest method getResultCountFromHeader.

@Test
public void getResultCountFromHeader() throws Exception {
    Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
    Producer producer = endpoint.createProducer();
    Exchange exchange = createExchangeWithInBody("SELECT * FROM cmis:document WHERE CONTAINS('Camel test content.')");
    producer.process(exchange);
    @SuppressWarnings("unchecked") List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
    assertEquals(2, documents.size());
    assertEquals(2, exchange.getOut().getHeader("CamelCMISResultCount"));
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) Map(java.util.Map) Test(org.junit.Test)

Example 2 with Producer

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

the class CMISQueryProducerTest method limitNumberOfResultsWithReadSizeHeader.

@Test
public void limitNumberOfResultsWithReadSizeHeader() throws Exception {
    Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
    Producer producer = endpoint.createProducer();
    Exchange exchange = createExchangeWithInBody("SELECT * FROM cmis:document WHERE CONTAINS('Camel test content.')");
    exchange.getIn().getHeaders().put("CamelCMISReadSize", 1);
    producer.process(exchange);
    @SuppressWarnings("unchecked") List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
    assertEquals(1, documents.size());
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) Map(java.util.Map) Test(org.junit.Test)

Example 3 with Producer

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

the class CMISQueryProducerTest method retrieveAlsoDocumentContent.

@Test
public void retrieveAlsoDocumentContent() throws Exception {
    Endpoint endpoint = context.getEndpoint("cmis://" + getUrl() + "?queryMode=true");
    Producer producer = endpoint.createProducer();
    Exchange exchange = createExchangeWithInBody("SELECT * FROM cmis:document WHERE cmis:name='test1.txt'");
    exchange.getIn().getHeaders().put("CamelCMISRetrieveContent", true);
    producer.process(exchange);
    @SuppressWarnings("unchecked") List<Map<String, Object>> documents = exchange.getOut().getBody(List.class);
    InputStream content = (InputStream) documents.get(0).get("CamelCMISContent");
    assertEquals("This is the first Camel test content.", readFromStream(content));
}
Also used : Exchange(org.apache.camel.Exchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) InputStream(java.io.InputStream) Map(java.util.Map) Test(org.junit.Test)

Example 4 with Producer

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

the class FopEndpointTest method encryptPdfWithUserPassword.

@Test
public void encryptPdfWithUserPassword() throws Exception {
    Endpoint endpoint = context().getEndpoint("fop:pdf");
    Producer producer = endpoint.createProducer();
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setHeader("CamelFop.Encrypt.userPassword", "secret");
    exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test Content"));
    producer.process(exchange);
    PDDocument document = getDocumentFrom(exchange);
    assertTrue(document.isEncrypted());
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) PDDocument(org.apache.pdfbox.pdmodel.PDDocument) Test(org.junit.Test)

Example 5 with Producer

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

the class FopEndpointTest method overridePdfOutputFormatToPlainText.

@Test
public void overridePdfOutputFormatToPlainText() throws Exception {
    String defaultOutputFormat = "pdf";
    Endpoint endpoint = context().getEndpoint("fop:" + defaultOutputFormat);
    Producer producer = endpoint.createProducer();
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setHeader(FopConstants.CAMEL_FOP_OUTPUT_FORMAT, "txt");
    exchange.getIn().setBody(FopHelper.decorateTextWithXSLFO("Test Content"));
    producer.process(exchange);
    String plainText = exchange.getOut().getBody(String.class).trim();
    assertEquals("Test Content", plainText);
}
Also used : DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Endpoint(org.apache.camel.Endpoint) Producer(org.apache.camel.Producer) Test(org.junit.Test)

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