}
}
public void testObjectOutputStreamPropagatesCloseAndFlushEvents() throws IOException {
// setup
final CallLog log = new CallLog();
Writer loggingWriter = new Writer() {
public void close() {
log.actual("close");
}
public void flush() {
log.actual("flush");
}
public void write(char cbuf[], int off, int len) {
// don't care about this
}
};
// 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();
// verify
log.verify();
}