use of org.apache.camel.ProducerTemplate in project camel by apache.
the class CdiCamelFactory method producerTemplateFromUri.
private static ProducerTemplate producerTemplateFromUri(InjectionPoint ip, @Any Instance<CamelContext> instance, CdiCamelExtension extension, Uri uri) {
try {
CamelContext context = uri.context().isEmpty() ? selectContext(ip, instance, extension) : selectContext(uri.context(), instance);
ProducerTemplate producerTemplate = context.createProducerTemplate();
Endpoint endpoint = context.getEndpoint(uri.value(), Endpoint.class);
producerTemplate.setDefaultEndpoint(endpoint);
return producerTemplate;
} catch (Exception cause) {
throw new InjectionException("Error injecting producer template annotated with " + uri + " into " + ip, cause);
}
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class ProgrammaticLookupTest method sendMessageToInbound.
@Test
public void sendMessageToInbound() throws InterruptedException {
ProducerTemplate inbound = producers.select(Uri.Literal.of("direct:inbound")).get();
MockEndpoint outbound = endpoints.select(MockEndpoint.class, Uri.Literal.of("mock:outbound")).get();
outbound.expectedMessageCount(1);
outbound.expectedBodiesReceived("test");
inbound.sendBody("test");
assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class ECDSASignatureTest method doSignatureRouteTest.
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(builder);
context.start();
MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
mock.setExpectedMessageCount(1);
ProducerTemplate template = context.createProducerTemplate();
if (e != null) {
template.send("direct:in", e);
} else {
template.sendBodyAndHeaders("direct:in", payload, headers);
}
assertMockEndpointsSatisfied();
return mock.getReceivedExchanges().get(0);
} finally {
context.stop();
}
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class SignatureTests method doSignatureRouteTest.
public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
CamelContext context = new DefaultCamelContext();
try {
context.addRoutes(builder);
context.start();
MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
mock.setExpectedMessageCount(1);
ProducerTemplate template = context.createProducerTemplate();
if (e != null) {
template.send("direct:in", e);
} else {
template.sendBodyAndHeaders("direct:in", payload, headers);
}
assertMockEndpointsSatisfied();
return mock.getReceivedExchanges().get(0);
} finally {
context.stop();
}
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class CxfEndpointBeansRouterTest method testCxfBusConfiguration.
@Test
public void testCxfBusConfiguration() throws Exception {
// get the camelContext from application context
CamelContext camelContext = ctx.getBean("camel", CamelContext.class);
ProducerTemplate template = camelContext.createProducerTemplate();
Exchange reply = template.request("cxf:bean:serviceEndpoint", new Processor() {
public void process(final Exchange exchange) {
final List<String> params = new ArrayList<String>();
params.add("hello");
exchange.getIn().setBody(params);
exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
}
});
Exception ex = reply.getException();
assertTrue("Should get the fault here", ex instanceof org.apache.cxf.interceptor.Fault || ex instanceof HTTPException);
}
Aggregations