StandaloneSession session = new StandaloneSession();
ByteArrayOutputStream out = new ByteArrayOutputStream();
SimpleOutputHandler handler = new SimpleOutputHandler( out, false );
MimeTypeListener listener = new MimeTypeListener();
handler.setMimeTypeListener( listener );
assertEquals( listener, handler.getMimeTypeListener() );
assertFalse( handler.allowFeedback() );
handler.setSession( session );
assertEquals( session, handler.getSession() );
handler.setContentItem( new SimpleContentItem(), null, null );
IContentItem content2 = handler.getOutputContentItem( "bogus", "testoutut:bogus", null, null );
assertEquals( TestOutputHandler.contentItem, content2 );
content2 = handler.getOutputContentItem( "bogus", "bogus", null, null );
assertNull( content2 );
content2 = handler.getOutputContentItem( IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null );
assertEquals( out, content2.getOutputStream( null ) );
assertFalse( handler.contentDone() );
assertNull( handler.getFeedbackContentItem() );
assertFalse( handler.contentDone() );
handler.setOutputPreference( -1 );
assertEquals( -1, handler.getOutputPreference() );
handler.setMimeType( "test/test" );
assertEquals( "test/test", handler.getMimeType() );
handler.setOutput( "bogus", null );
handler.setOutput( "file:bogus", null );
IContentItem content3 = new BufferedContentItem( null );
OutputStream os = content3.getOutputStream( null );
os.write( "test data".getBytes() );
content3.closeOutputStream();
handler.setOutput( IOutputHandler.CONTENT, content3 );
assertEquals( "test data", new String( out.toByteArray() ) );
handler.setOutput( IOutputHandler.CONTENT, "+test data2" );
assertEquals( "test data+test data2", new String( out.toByteArray() ) );
}