public class ExchangeImplTest {
@Test
public void testWrite() throws Exception {
Exchange e = new ExchangeImpl(Pattern.InOnly);
e.setOperation(new QName("op"));
e.setProperty("key", "value");
e.setStatus(Status.Done);
Message msg = e.getIn();
msg.setHeader("header", "value");
msg.addAttachment("id", "att");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(baos);
os.writeObject(e);
os.close();
ObjectInputStream is = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
Exchange cpy = (Exchange) is.readObject();
assertNotNull(cpy);
assertEquals(e.getId(), cpy.getId());
assertEquals(e.getStatus(), cpy.getStatus());
assertEquals(e.getRole(), cpy.getRole());
assertEquals(e.getPattern(), cpy.getPattern());
assertEquals(e.getOperation(), cpy.getOperation());
assertEquals(e.getProperty("key"), cpy.getProperty("key"));
assertNotNull(cpy.getIn());
assertNotNull(cpy.getIn().getHeader("header"));
assertNotNull(cpy.getIn().getAttachment("id"));
}