use of org.apache.camel.Message in project camel by apache.
the class SpringLdapProducerTest method testNoDNForFunctionDrivenOperation.
@Test
public void testNoDNForFunctionDrivenOperation() throws Exception {
Exchange exchange = new DefaultExchange(context);
Message in = new DefaultMessage();
Map<String, Object> body = new HashMap<String, Object>();
body.put(SpringLdapProducer.FUNCTION, Mockito.mock(BiFunction.class));
when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.FUNCTION_DRIVEN);
processBody(exchange, in, body);
}
use of org.apache.camel.Message in project camel by apache.
the class SpringLdapProducerTest method testEmptyDN.
@Test(expected = UnsupportedOperationException.class)
public void testEmptyDN() throws Exception {
Exchange exchange = new DefaultExchange(context);
Message in = new DefaultMessage();
Map<String, Object> body = new HashMap<String, Object>();
body.put(SpringLdapProducer.DN, "");
processBody(exchange, in, body);
}
use of org.apache.camel.Message in project camel by apache.
the class MyProcessor method process.
public void process(Exchange exchange) {
Message in = exchange.getIn();
in.setBody(in.getBody(String.class) + " World!");
}
use of org.apache.camel.Message in project camel by apache.
the class SshProducer method process.
@Override
public void process(Exchange exchange) throws Exception {
final Message in = exchange.getIn();
String command = in.getMandatoryBody(String.class);
try {
SshResult result = SshHelper.sendExecCommand(command, endpoint, client);
exchange.getOut().setBody(result.getStdout());
exchange.getOut().setHeader(SshResult.EXIT_VALUE, result.getExitValue());
exchange.getOut().setHeader(SshResult.STDERR, result.getStderr());
} catch (Exception e) {
throw new CamelExchangeException("Cannot execute command: " + command, exchange, e);
}
// propagate headers and attachments
exchange.getOut().getHeaders().putAll(in.getHeaders());
exchange.getOut().setAttachments(in.getAttachments());
}
use of org.apache.camel.Message in project camel by apache.
the class SshComponentErrorHandlingTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() {
errorHandler(deadLetterChannel("mock:error").maximumRedeliveries(3).redeliveryDelay(// speedup unit test by not waiting between redeliveries
0L).onRedelivery(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
final Message in = exchange.getIn();
final int count = in.getHeader(Exchange.REDELIVERY_COUNTER, Integer.class);
final int maxCount = in.getHeader(Exchange.REDELIVERY_MAX_COUNTER, Integer.class);
log.info("Redelivery count = {}", count);
// Restart the sshd server before the last redelivery attempt
if (count >= (maxCount - 1)) {
if (sshd != null) {
sshd.start();
log.info("Restarting SSHD");
}
}
}
}));
from("direct:redeliver").tracing().to("ssh://smx:smx@localhost:" + port).to("mock:success");
}
};
}
Aggregations