Java Code Examples for org.apache.camel.CamelContext#setLoadTypeConverters()

The following examples show how to use org.apache.camel.CamelContext#setLoadTypeConverters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomConverterTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
@Test
public void testMarshal() throws Exception {

    CamelContext camelctx = new DefaultCamelContext(false);
    camelctx.setLoadTypeConverters(true);
    camelctx.init();
    
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start").convertBodyTo(Map.class);
        }
    });

    camelctx.start();
    try {
        ProducerTemplate producer = camelctx.createProducerTemplate();
        Map<?, ?> result = producer.requestBody("direct:start", new Customer("John", "Doe"), Map.class);
        Assert.assertEquals("{firstName=John, lastName=Doe}", result.toString());
    } finally {
        camelctx.close();
    }
}
 
Example 2
Source File: CustomConverterTest.java    From wildfly-camel with Apache License 2.0 6 votes vote down vote up
public void testUnmarshal() throws Exception {

        CamelContext camelctx = new DefaultCamelContext();
        camelctx.setLoadTypeConverters(true);
        
        camelctx.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("direct:start").convertBodyTo(Customer.class);
            }
        });

        Map<String, String> input = new LinkedHashMap<String, String>();
        input.put("firstName", "John");
        input.put("lastName", "Doe");

        camelctx.start();
        try {
            ProducerTemplate producer = camelctx.createProducerTemplate();
            Customer result = producer.requestBody("direct:start", input, Customer.class);
            Assert.assertEquals("John", result.getFirstName());
            Assert.assertEquals("Doe", result.getLastName());
        } finally {
            camelctx.close();
        }
    }
 
Example 3
Source File: TestCustomizer.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public void apply(CamelContext camelContext) {
    camelContext.setMessageHistory(messageHistory);
    camelContext.setLoadTypeConverters(false);
}