ds = omse.getDataSource();
assertTrue(ds instanceof JAXBBlockImpl);
// Simulate transport
ByteArrayOutputStream baos = new ByteArrayOutputStream();
OMOutputFormat outputFormat = new OMOutputFormat();
outputFormat.setDoOptimize(true);
outputFormat.setMimeBoundary("MIMEBoundary_Axis2Rocks");
env.serializeAndConsume(baos, outputFormat);
// Make sure the output is correct
String newText = baos.toString();
System.out.println(newText);
assertTrue(newText.contains("soap"));
assertTrue(newText.contains("Envelope"));
assertTrue(newText.contains("Body"));
assertTrue(newText.indexOf("MIMEBoundary_Axis2Rocks") > 0);
assertTrue(newText.indexOf(sampleText) > 0);
assertTrue(newText.indexOf("<soapenv:Body><sendImage xmlns=\"urn://mtom.test.org\"><input><imageData><xop:Include") > 0);
// Now read in the persisted message
// Setup an input stream to the file
FileInputStream inStream = new FileInputStream(theFile);
// attach a stream capable of reading objects from the
// stream connected to the file
ObjectInputStream inObjStream = new ObjectInputStream(inStream);
// try to restore the message context
System.out.println("restoring a message context.....");
org.apache.axis2.context.MessageContext restoredMC =
(org.apache.axis2.context.MessageContext) inObjStream.readObject();
inObjStream.close();
inStream.close();
System.out.println("....restored message context.....");
// At this point in time, the restoredMessage will be a full tree.
// TODO If this changes, please add more assertions here.
// Simulate transport on the restored message
baos = new ByteArrayOutputStream();
env = restoredMC.getEnvelope();
outputFormat = new OMOutputFormat();
outputFormat.setDoOptimize(true);
outputFormat.setMimeBoundary("MIMEBoundary_Axis2Rocks");
env.serializeAndConsume(baos, outputFormat);
String restoredText = baos.toString();
System.out.println(restoredText);
assertTrue(restoredText.contains("soap"));
assertTrue(restoredText.contains("Envelope"));