use of org.apache.camel.Processor in project camel by apache.
the class RoutingUsingCamelContextFactoryTest method testXMLRouteLoading.
public void testXMLRouteLoading() throws Exception {
applicationContext = createApplicationContext();
SpringCamelContext context = applicationContext.getBean("camel-A", SpringCamelContext.class);
assertValidContext(context);
MockEndpoint resultEndpoint = (MockEndpoint) resolveMandatoryEndpoint(context, "mock:result");
resultEndpoint.expectedBodiesReceived(body);
// now lets send a message
ProducerTemplate template = context.createProducerTemplate();
template.start();
template.send("seda:start", new Processor() {
public void process(Exchange exchange) {
Message in = exchange.getIn();
in.setHeader("name", "James");
in.setBody(body);
}
});
template.stop();
resultEndpoint.assertIsSatisfied();
}
use of org.apache.camel.Processor in project camel by apache.
the class SpringSetFaultBodyTest method testSetFaultBody.
public void testSetFaultBody() throws Exception {
Exchange out = template.request("direct:start", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
exchange.getIn().setBody("Hello World");
}
});
assertNotNull(out);
assertEquals("Bye World", out.getIn().getBody());
assertTrue("Should be a fault body", out.getIn().isFault());
}
use of org.apache.camel.Processor in project camel by apache.
the class MinaManyUDPMessagesTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
//context.setTracing(true);
DataFormat syslogDataFormat = new SyslogDataFormat();
// we setup a Syslog listener on a random port.
from("mina2:udp://127.0.0.1:" + serverPort).unmarshal(syslogDataFormat).process(new Processor() {
public void process(Exchange ex) {
assertTrue(ex.getIn().getBody() instanceof SyslogMessage);
}
}).to("mock:stop1").marshal(syslogDataFormat).to("mock:stop2");
}
};
}
use of org.apache.camel.Processor in project camel by apache.
the class NettyDataFormatTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
context.setTracing(true);
DataFormat syslogDataFormat = new SyslogDataFormat();
// we setup a Syslog listener on a random port.
from("netty4:udp://127.0.0.1:" + serverPort + "?sync=false&allowDefaultCodec=false").unmarshal(syslogDataFormat).process(new Processor() {
public void process(Exchange ex) {
assertTrue(ex.getIn().getBody() instanceof SyslogMessage);
SyslogMessage message = ex.getIn().getBody(SyslogMessage.class);
}
}).to("mock:syslogReceiver").marshal(syslogDataFormat).to("mock:syslogReceiver2");
}
};
}
use of org.apache.camel.Processor in project camel by apache.
the class NettyRfc5425LongMessageTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
context().getRegistry(JndiRegistry.class).bind("rfc5426FrameDecoder", new Rfc5425FrameDecoder());
return new RouteBuilder() {
@Override
public void configure() throws Exception {
context.setTracing(true);
DataFormat syslogDataFormat = new SyslogDataFormat();
// we setup a Syslog listener on a random port.
from(uri).unmarshal(syslogDataFormat).process(new Processor() {
@Override
public void process(Exchange ex) {
assertTrue(ex.getIn().getBody() instanceof SyslogMessage);
}
}).to("mock:syslogReceiver").marshal(syslogDataFormat).to("mock:syslogReceiver2");
// Here we need to turn the request body into ByteBuf
from("direct:start").convertBodyTo(ByteBuf.class).to(uri);
}
};
}
Aggregations