ByteArrayOutputStream serverResponseCollector = new ByteArrayOutputStream();
serverResponseCollector.write( "* OK IMAP4rev1 Server XXX ready".getBytes() );
serverResponseCollector.write( '\r' );
serverResponseCollector.write( '\n' );
ImapSession session = getImapSession();
ImapRequestHandler requestHandler = new ImapRequestHandler();
while( requestHandler.handleRequest( clientIn, serverResponseCollector, session ) ) {};
InputStream serverInstream = new ByteArrayInputStream( serverResponseCollector.toByteArray() );
BufferedReader serverIn = new BufferedReader( new InputStreamReader( serverInstream ) );