assertTrue(xmlResult.contains("Gallia:string2"));
}
@Test
public void testMarshallIntoStax() throws Exception {
GreetMe obj = new GreetMe();
obj.setRequestType("Hello");
QName elName = new QName(wrapperAnnotation.targetNamespace(),
wrapperAnnotation.localName());
MessagePartInfo part = new MessagePartInfo(elName, null);
part.setElement(true);
part.setElementQName(elName);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
XMLEventWriter writer = opFactory.createXMLEventWriter(baos);
//STARTDOCUMENT/ENDDOCUMENT is not required
//writer.add(eFactory.createStartDocument("utf-8", "1.0"));
JAXBEncoderDecoder.marshall(context.createMarshaller(), obj, part, writer);
//writer.add(eFactory.createEndDocument());
writer.flush();
writer.close();
//System.out.println(baos.toString());
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
XMLInputFactory ipFactory = XMLInputFactory.newInstance();
XMLEventReader reader = ipFactory.createXMLEventReader(bais);
Unmarshaller um = context.createUnmarshaller();
Object val = um.unmarshal(reader, GreetMe.class);
assertTrue(val instanceof JAXBElement);
val = ((JAXBElement<?>)val).getValue();
assertTrue(val instanceof GreetMe);
assertEquals(obj.getRequestType(),
((GreetMe)val).getRequestType());
}