use of org.apache.camel.impl.transformer.DataFormatTransformer in project camel by apache.
the class TransformerBuilderTest method testDataFormatTransformer.
public void testDataFormatTransformer() throws Exception {
CamelContext ctx = new DefaultCamelContext();
RouteBuilder builder = new RouteBuilder() {
@Override
public void configure() throws Exception {
transformer().fromType("xml:foo").toType("json:bar").withDataFormat(new StringDataFormat());
from("direct:input").log("test");
}
};
ctx.addRoutes(builder);
ctx.start();
Transformer transformer = ctx.resolveTransformer(new DataType("xml:foo"), new DataType("json:bar"));
assertNotNull(transformer);
assertEquals(DataFormatTransformer.class, transformer.getClass());
DataFormatTransformer dft = (DataFormatTransformer) transformer;
Field f = DataFormatTransformer.class.getDeclaredField("dataFormatType");
f.setAccessible(true);
Object dataFormatType = f.get(dft);
assertEquals(StringDataFormat.class, dataFormatType.getClass());
}
Aggregations