InputStream is = new ByteArrayInputStream(buffers);
Exchange exchange = new DefaultExchange(context);
exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
exchange.setProperty(Exchange.FILTER_NON_XML_CHARS, true);
TypeConverter converter = context.getTypeConverter();
PersonType person = converter.convertTo(PersonType.class, exchange, is);
assertNotNull("Person should not be null ", person);
assertEquals("Get the wrong first name ", "FOO", person.getFirstName());
assertEquals("Get the wrong second name ", "BAR ", person.getLastName());
person.setLastName("BAR\u0008\uD8FF");
String value = converter.convertTo(String.class, exchange, person);
assertTrue("Didn't filter the non-xml chars", value.indexOf("<lastName>BAR </lastName>") > 0);
exchange.setProperty(Exchange.FILTER_NON_XML_CHARS, false);