use of org.apache.cxf.jaxb.fortest.unqualified.UnqualifiedBean in project cxf by apache.
the class JAXBDataBindingTest method testContextProperties.
@Test
public void testContextProperties() throws Exception {
JAXBDataBinding db = new JAXBDataBinding();
Map<String, String> nsMap = new HashMap<>();
nsMap.put("uri:ultima:thule", "");
db.setNamespaceMap(nsMap);
Map<String, Object> contextProperties = new HashMap<>();
contextProperties.put("com.sun.xml.bind.defaultNamespaceRemap", "uri:ultima:thule");
db.setContextProperties(contextProperties);
Set<Class<?>> classes = new HashSet<Class<?>>();
classes.add(UnqualifiedBean.class);
db.setContext(db.createJAXBContext(classes));
DataWriter<XMLStreamWriter> writer = db.createWriter(XMLStreamWriter.class);
XMLOutputFactory writerFactory = XMLOutputFactory.newInstance();
StringWriter stringWriter = new StringWriter();
XMLStreamWriter xmlWriter = writerFactory.createXMLStreamWriter(stringWriter);
UnqualifiedBean bean = new UnqualifiedBean();
bean.setAriadne("spider");
writer.write(bean, xmlWriter);
xmlWriter.flush();
String xml = stringWriter.toString();
assertTrue(xml, xml.contains("uri:ultima:thule"));
}
Aggregations