@Test
public void testGetMimeType() throws Exception {

  String mimeType;
  mimeType = sra.getMimeType( "" );
  assertEquals( mimeType, sra.MIME_GENERIC_FALLBACK );
  MasterReport report = mock( MasterReport.class );
  Configuration config = mock( Configuration.class );
  doReturn( config ).when( report ).getConfiguration();
  doNothing().when( report ).setReportEnvironment( any( ReportEnvironment.class ) );
  sra.setReport( report );
  mimeType = sra.getMimeType();
  assertEquals( "text/html", mimeType );
  doReturn( true ).when( report ).getAttribute( AttributeNames.Core.NAMESPACE,
      AttributeNames.Core.LOCK_PREFERRED_OUTPUT_TYPE );
  doReturn( "pageable/X-AWT-Graphics;image-type=png" ).when( report )
      .getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.PREFERRED_OUTPUT_TYPE );
  sra.setReport( report );
  mimeType = sra.getMimeType();
  assertEquals( "image/png", mimeType );
  Map<String, String> map = new HashMap<String, String>() {
    {
      put( "text/csv", "text/csv" );
      put( "text/html", "text/html" );
      put( "application/xml", "application/xml" );
      put( "application/pdf", "application/pdf" );
      put( "application/rtf", "application/rtf" );
      put( "application/vnd.ms-excel", "application/vnd.ms-excel" );
      put( "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
        "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" );
      put( "mime-message/text/html", "mime-message/text/html" );
      put( "text/plain", "text/plain" );
      put( "pdf", "application/pdf" );
      put( "html", "text/html" );
      put( "csv", "text/csv" );
      put( "rtf", "application/rtf" );
      put( "xls", "application/vnd.ms-excel" );
      put( "txt", "text/plain" );
    }
  };
  for ( int i = 0; i < map.size(); i++ ) {
    String key = map.keySet().toArray()[ i ].toString();
    doReturn( key ).when( report )
        .getAttribute( AttributeNames.Core.NAMESPACE, AttributeNames.Core.PREFERRED_OUTPUT_TYPE );
    mimeType = sra.getMimeType();
    assertEquals( map.get( key ), mimeType );
    sra.setPaginateOutput( true );
    mimeType = sra.getMimeType();
    assertEquals( map.get( key ), mimeType );
    sra.setPaginateOutput( false );
  }
}