import junit.framework.TestCase;
public class MessageExchangeImplTest extends TestCase {
protected void testSerializeDeserialize(Source src) throws Exception {
MessageExchange me = new InOnlyImpl("exchangeId");
me.setProperty("myProp", "myValue");
NormalizedMessage msg = me.createMessage();
msg.setProperty("myMsgProp", "myMsgValue");
msg.setContent(src);
//msg.addAttachment("myAttachment", null);
me.setMessage(msg, "in");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(me);
oos.close();
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
ObjectInputStream ois = new ObjectInputStream(bais);
Object out = ois.readObject();
assertNotNull(out);
assertTrue(out instanceof MessageExchange);
MessageExchange meOut = (MessageExchange) out;
assertEquals("myValue", meOut.getProperty("myProp"));
NormalizedMessage msgOut = meOut.getMessage("in");
assertNotNull(msgOut);
assertEquals("myMsgValue", msgOut.getProperty("myMsgProp"));
Source outSrc = msgOut.getContent();
assertNotNull(outSrc);
String outStr = new SourceTransformer().toString(outSrc);