public void testContext() throws Exception {
SOAPBindingImpl binding = new SOAPBindingImpl(false);
ObjectMessageContextImpl objContext = new ObjectMessageContextImpl();
objContext.setMethod(SOAPMessageUtil.getMethod(Greeter.class, "greetMe"));
SOAPMessageContext soapContext = (SOAPMessageContext)binding.createBindingMessageContext(objContext);
soapContext.put(ObjectMessageContext.MESSAGE_INPUT, false);
String arg0 = new String("TestSOAPInputPMessage");
objContext.setMessageObjects(arg0);
binding.marshal(objContext,
soapContext,
new JAXBDataBindingCallback(objContext.getMethod(),
DataBindingCallback.Mode.PARTS,
null));
SOAPMessage msg = soapContext.getMessage();
PersistenceUtils pu = new PersistenceUtils();
InputStream is = pu.getContextAsInputStream(soapContext);
assert null != is;
MessageContext restored = pu.getContext(is);
assertEquals(3, restored.keySet().size());
assertEquals(soapContext.get(ObjectMessageContext.MESSAGE_INPUT),
restored.get(ObjectMessageContext.MESSAGE_INPUT));
Object[] params = (Object[])soapContext.get(ObjectMessageContext.METHOD_PARAMETERS);
Object[] restoredParams = (Object[])restored.get(ObjectMessageContext.METHOD_PARAMETERS);
assertEquals(params.length, restoredParams.length);
assertEquals(params[0], restoredParams[0]);
SOAPMessage restoredMsg = ((SOAPMessageContext)binding.
createBindingMessageContext(objContext)).getMessage();