Search in sources :

Example 6 with Endpoint

use of org.apache.camel.Endpoint 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 7 with Endpoint

use of org.apache.camel.Endpoint 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 8 with Endpoint

use of org.apache.camel.Endpoint 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 9 with Endpoint

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

the class CouchbaseComponentTest method testEndpointCreated.

@Test
public void testEndpointCreated() throws Exception {
    Map<String, Object> params = new HashMap<String, Object>();
    String uri = "couchbase:http://localhost:9191/bucket";
    String remaining = "http://localhost:9191/bucket";
    Endpoint endpoint = new CouchbaseComponent(context).createEndpoint(uri, remaining, params);
    assertNotNull(endpoint);
}
Also used : Endpoint(org.apache.camel.Endpoint) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 10 with Endpoint

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

the class AbstractCamelFluentProducerTemplateFactoryBean method getObject.

public FluentProducerTemplate getObject() throws Exception {
    CamelContext context = getCamelContext();
    if (defaultEndpoint != null) {
        Endpoint endpoint = context.getEndpoint(defaultEndpoint);
        if (endpoint == null) {
            throw new IllegalArgumentException("No endpoint found for URI: " + defaultEndpoint);
        } else {
            template = new DefaultFluentProducerTemplate(context);
            template.setDefaultEndpoint(endpoint);
        }
    } else {
        template = new DefaultFluentProducerTemplate(context);
    }
    // set custom cache size if provided
    if (maximumCacheSize != null) {
        template.setMaximumCacheSize(maximumCacheSize);
    }
    // must start it so its ready to use
    ServiceHelper.startService(template);
    return template;
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultFluentProducerTemplate(org.apache.camel.builder.DefaultFluentProducerTemplate) Endpoint(org.apache.camel.Endpoint)

Aggregations

Endpoint (org.apache.camel.Endpoint)564 Test (org.junit.Test)206 Exchange (org.apache.camel.Exchange)201 Producer (org.apache.camel.Producer)137 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)89 Processor (org.apache.camel.Processor)43 Message (org.apache.camel.Message)38 CamelContext (org.apache.camel.CamelContext)32 HashMap (java.util.HashMap)28 Map (java.util.Map)28 Consumer (org.apache.camel.Consumer)27 RouteBuilder (org.apache.camel.builder.RouteBuilder)24 File (java.io.File)21 Route (org.apache.camel.Route)21 EventDrivenConsumerRoute (org.apache.camel.impl.EventDrivenConsumerRoute)18 CountDownLatch (java.util.concurrent.CountDownLatch)16 DefaultExchange (org.apache.camel.impl.DefaultExchange)16 SpanDecorator (org.apache.camel.opentracing.SpanDecorator)15 ArrayList (java.util.ArrayList)14 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)14