// expectations
log.expect("flush"); // TWO flushes are currently caused. Only one is needed, but
// this is no big deal.
log.expect("flush");
log.expect("close");
// execute
ObjectOutputStream objectOutputStream = xstream.createObjectOutputStream(loggingWriter);
objectOutputStream.flush();
objectOutputStream.close();