JaxbUtils { public static <T> Document marshalToDocument(T object) throws JAXBException { Marshaller marshaller = buildMarshaller(object); Document document = DocumentUtils.createDocument(); marshaller.marshal(object, document); return document; } private  JaxbUtils(); static Marshaller buildMarshaller(T object); static String marshalToString(T object); static Document marshalToDocument(T object); static Unmarshaller buildUnmarshaller(Class... clazz); static T unmarshal(String message, Class... clazz); static T unmarshal(Node message, Class... clazz); static boolean isObjectContainNull(Object object); static boolean isGetValueNull(Object object, Method method); static List<Document> objectsToDocument(List<Object> objects); static Node buildPayloadObject(T object);  }
@Test public void marshalToDocument() throws Exception { RpcReplyV11 rpcReplyV11 = new RpcReplyV11(); rpcReplyV11.setMessageId(MESSAGE_ID); Document document = JaxbUtils.marshalToDocument(rpcReplyV11); assertEquals("rpc-reply", document.getFirstChild().getLocalName()); RpcReplyV11 rpcReplyUnmarshal = JaxbUtils.unmarshal(document, RpcReplyV11.class); assertEquals(rpcReplyV11.getMessageId(), rpcReplyUnmarshal.getMessageId()); }