*/
// [Issue-2], serialization
public void testWriteConfigs() throws Exception
{
JacksonXMLProvider prov = new JacksonXMLProvider();
ByteArrayOutputStream out = new ByteArrayOutputStream();
Bean bean = new Bean();
Method m = getClass().getDeclaredMethod("writeConfig");
JacksonFeatures feats = m.getAnnotation(JacksonFeatures.class);
assertNotNull(feats); // just a sanity check
/* 09-Oct-2013, tatu: As of 2.3, XML backend does NOT add extra wrapping
* any more: it is only added to JSON where it is needed; but not
* to XML which always basically uses wrapping.
*/
try {
prov.writeTo(bean, bean.getClass(), bean.getClass(), new Annotation[] { feats },
MediaType.APPLICATION_JSON_TYPE, null, out);
} catch (Exception e) {
throw unwrap(e);
}
//
assertEquals("<Bean><a>3</a></Bean>", out.toString("UTF-8"));
// but without, not:
out.reset();
prov.writeTo(bean, bean.getClass(), bean.getClass(), new Annotation[] { },
MediaType.APPLICATION_JSON_TYPE, null, out);
assertEquals("<Bean><a>3</a></Bean>", out.toString("UTF-8"));
}