Search in sources :

Example 1 with Foo

use of org.apache.camel.example.Foo in project camel by apache.

the class CamelJaxbFallbackConverterTest method testFallbackConverterWithoutObjectFactory.

@Test
public void testFallbackConverterWithoutObjectFactory() throws Exception {
    TypeConverter converter = context.getTypeConverter();
    Foo foo = converter.convertTo(Foo.class, "<foo><zot name=\"bar1\" value=\"value\" otherValue=\"otherValue\"/></foo>");
    assertNotNull("foo should not be null", foo);
    assertEquals("value", foo.getBarRefs().get(0).getValue());
    foo.getBarRefs().clear();
    Bar bar = new Bar();
    bar.setName("myName");
    bar.setValue("myValue");
    foo.getBarRefs().add(bar);
    Exchange exchange = new DefaultExchange(context);
    exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
    String value = converter.convertTo(String.class, exchange, foo);
    assertTrue("Should get a right marshalled string", value.indexOf("<bar name=\"myName\" value=\"myValue\"/>") > 0);
}
Also used : TypeConverter(org.apache.camel.TypeConverter) DefaultExchange(org.apache.camel.impl.DefaultExchange) Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Bar(org.apache.camel.example.Bar) Foo(org.apache.camel.example.Foo) Test(org.junit.Test)

Aggregations

Exchange (org.apache.camel.Exchange)1 TypeConverter (org.apache.camel.TypeConverter)1 Bar (org.apache.camel.example.Bar)1 Foo (org.apache.camel.example.Foo)1 DefaultExchange (org.apache.camel.impl.DefaultExchange)1 Test (org.junit.Test)1