use of org.apache.camel.example.Bar 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);
}
Aggregations