WriteRequest wrs[] = new WriteRequest[] {
new WriteRequest( new Object() ),
new WriteRequest( new Object() ),
new WriteRequest( new Object() )
};
Queue queue = new Queue();
queue.push( wrs[ 0 ] );
queue.push( wrs[ 1 ] );
queue.push( wrs[ 2 ] );
InputStream stream = new ByteArrayInputStream( new byte[ 0 ] );
/*
* Record expectations
*/
mockSession.reset();
session.getAttribute( StreamWriteFilter.CURRENT_STREAM );
mockSession.setReturnValue( stream );
session.removeAttribute( StreamWriteFilter.CURRENT_STREAM );
mockSession.setReturnValue( stream );
session.removeAttribute( StreamWriteFilter.INITIAL_WRITE_FUTURE );
mockSession.setReturnValue( new WriteFuture() );
session.removeAttribute( StreamWriteFilter.WRITE_REQUEST_QUEUE );
mockSession.setReturnValue( queue );
nextFilter.filterWrite( session, wrs[ 0 ] );
session.getAttribute( StreamWriteFilter.CURRENT_STREAM );
mockSession.setReturnValue( null );
nextFilter.filterWrite( session, wrs[ 1 ] );
session.getAttribute( StreamWriteFilter.CURRENT_STREAM );
mockSession.setReturnValue( null );
nextFilter.filterWrite( session, wrs[ 2 ] );
session.getAttribute( StreamWriteFilter.CURRENT_STREAM );
mockSession.setReturnValue( null );
nextFilter.messageSent( session, stream );
/*
* Replay.
*/
mockNextFilter.replay();
mockSession.replay();
filter.messageSent( nextFilter, session, new Object() );
assertEquals( 0, queue.size() );
/*
* Verify.
*/
mockNextFilter.verify();