use of org.apache.camel.spi.DataFormat 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.spi.DataFormat 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);
}
};
}
use of org.apache.camel.spi.DataFormat in project camel by apache.
the class NettyRfc5425Test 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");
from("direct:checkStructuredData").unmarshal(syslogDataFormat).process(new Processor() {
@Override
public void process(Exchange ex) {
Object body = ex.getIn().getBody();
assertTrue(body instanceof Rfc5424SyslogMessage);
assertEquals("[exampleSDID@32473 iut=\"3\" eventSource=\"Application\" eventID=\"1011\"]", ((Rfc5424SyslogMessage) body).getStructuredData());
}
}).to("mock:syslogReceiver");
}
};
}
use of org.apache.camel.spi.DataFormat in project camel by apache.
the class DataFormatTestCommand method executeTest.
@Override
public Boolean executeTest(ITestConfig config, String dataFormat) throws Exception {
logger.info("Getting Camel dataFormat: {}", dataFormat);
DataFormat df = context.resolveDataFormat(dataFormat);
assertNotNull("Cannot get dataformat with name: " + dataFormat, df);
logger.info("Found Camel dataformat: {} instance: {} with className: {}", dataFormat, df, df.getClass());
return true;
}
use of org.apache.camel.spi.DataFormat in project camel by apache.
the class HttpAsyncDslTest method createRouteBuilder.
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
// START SNIPPET: e1
// just a unit test but imaging using your own data format that does complex
// and CPU heavy processing for decrypting the message
DataFormat mySecureDataFormat = new StringDataFormat("iso-8859-1");
// list on the JMS queue for new orders
from("jms:queue:order").to("bean:validateOrder").to("mock:validate").threads(20).unmarshal(mySecureDataFormat).delay(500).to("bean:handleOrder").to("mock:order");
// END SNIPPET: e1
}
};
}
Aggregations