Java Code Examples for org.pentaho.reporting.libraries.resourceloader.ResourceManager

The following examples show how to use org.pentaho.reporting.libraries.resourceloader.ResourceManager. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
protected DataFactory createDataFactory( final String query ) throws ReportDataFactoryException {
  try {
    URL res = getClass().getResource( "embedded-row-gen.ktr" );
    assertNotNull( res );

    ResourceManager mgr = new ResourceManager();
    ResourceKey key = mgr.createKey( res );
    final byte[] resource = mgr.load( key ).getResource( mgr );
    final EmbeddedKettleTransformationProducer producer =
      new EmbeddedKettleTransformationProducer( new FormulaArgument[ 0 ], new FormulaParameter[ 0 ], "dummy-id",
        resource );

    final KettleDataFactory kettleDataFactory = new KettleDataFactory();
    kettleDataFactory.initialize( new DesignTimeDataFactoryContext() );
    kettleDataFactory.setQuery( DEFAULT, producer );
    return kettleDataFactory;
  } catch ( ResourceException re ) {
    throw new ReportDataFactoryException( "Failed to load raw-data", re );
  }
}
 
Example 2
@Test
public void testTextRendering() throws Exception {
  URL resource = getClass().getResource( "Prd-5321.prpt" );
  ResourceManager mgr = new ResourceManager();
  MasterReport report = (MasterReport) mgr.createDirectly( resource, MasterReport.class ).getResource();
  report.getReportConfiguration().setConfigProperty( ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY,
      "false" );

  LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  ModelPrinter.INSTANCE.print( logicalPageBox );

  Assert.assertEquals( 6,
      MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_BOX_PARAGRAPH ).length );
  Assert.assertEquals( 13,
      MatchFactory.findElementsByNodeType( logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT ).length );

  TestPdfLogicalPageDrawable pdf = createDrawableForTest( report, logicalPageBox );
  pdf.draw();
  Assert.assertEquals( 13, pdf.textRendering );
}
 
Example 3
public void testPageFooter() throws Exception {
  final URL resource = getClass().getResource( "Prd-4634.prpt" );
  assertNotNull( resource );

  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final MasterReport report = (MasterReport) mgr.createDirectly( resource, MasterReport.class ).getResource();

  final GlobalAuthenticationStore globalAuthenticationStore = new GlobalAuthenticationStore();
  final ReportRenderContext reportContext =
    new ReportRenderContext( report, report, null, globalAuthenticationStore );
  final TestRootBandRenderer r = new TestRootBandRenderer( report.getPageFooter(), reportContext );

  final ValidateTextGraphics graphics2D = new ValidateTextGraphics( 468, 108 );
  assertTrue( graphics2D.hitClip( 10, 10, 1, 1 ) );
  r.draw( graphics2D );
}
 
Example 4
@Test
public void testHTML() throws ResourceException, IOException {

  URL url = getClass().getResource( "BACKLOG-6818.prpt" );

  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();

  try ( ByteArrayOutputStream stream = new ByteArrayOutputStream() ) {
    HtmlReportUtil.createStreamHTML( report, stream );

    final String html = new String( stream.toByteArray(), "UTF-8" );
    int k = 1;
    for ( int i = 1; i < 5; i++, k = -k ) {
      final Pattern pattern = Pattern.compile( "(.*id=\"test" + i + "\".*style=\")(.*)(\".*)" );
      final Matcher matcher = pattern.matcher( html );
      if ( matcher.find() ) {
        final String group = matcher.group( 2 );
        assertTrue( group.contains( k > 0 ? TextRotation.D_90.getCss() : TextRotation.D_270.getCss() ) );
      }
    }
  } catch ( final IOException | ReportProcessingException e ) {
    fail();
  }
}
 
Example 5
public void testQueryOnly() throws ReportDataFactoryException {
  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();

  final DataFactoryScriptingSupport support = new DataFactoryScriptingSupport();
  support.initialize( new TableDataFactory(),
      new DesignTimeDataFactoryContext( ClassicEngineBoot.getInstance().getGlobalConfig(), mgr, new ResourceKey(
          "dummy", "dummy", new HashMap() ), new DefaultResourceBundleFactory() ) );
  support.setQuery( "test", "test-query", null, null );
  support.setQuery( "test-script", "test-query-2", "JavaScript", queryScript2 );

  assertEquals( "test-query", support.computeQuery( "test", new ParameterDataRow() ) );
  assertEqualsArray( null, support.computeAdditionalQueryFields( "test", new ParameterDataRow() ) );
  assertEquals( "result", support.computeQuery( "test-script", new ParameterDataRow() ) );
  assertEqualsArray( null, support.computeAdditionalQueryFields( "test-script", new ParameterDataRow() ) );
  support.shutdown();
}
 
Example 6
/**
 * Returns the report definition which will be used to generate the report. In this case, the report will be
 * loaded and parsed from a file contained in this package.
 *
 * @return the loaded and parsed report definition to be used in report generation.
 */
public MasterReport getReportDefinition() {
  try {
    // Using the classloader, get the URL to the reportDefinition file
    final ClassLoader classloader = this.getClass().getClassLoader();
    final URL reportDefinitionURL = classloader.getResource( "org/pentaho/reporting/engine/classic/samples/Sample1.prpt" );

    // Parse the report file
    final ResourceManager resourceManager = new ResourceManager();
    final Resource directly = resourceManager.createDirectly( reportDefinitionURL, MasterReport.class );
    return (MasterReport) directly.getResource();
  } catch ( ResourceException e ) {
    e.printStackTrace();
  }
  return null;
}
 
Example 7
@Test
public void testReportRunCache() throws Exception {
  Assert.assertEquals( EhCacheDataCache.class.getName(), cache );
  Assert.assertEquals( TestCacheBackend.class.getName(), ClassicEngineBoot.getInstance().getGlobalConfig()
      .getConfigProperty( DataCache.class.getName() ) );

  MasterReport resource =
      (MasterReport) new ResourceManager().createDirectly( getClass().getResource( "Prd-5316.prpt" ),
          MasterReport.class ).getResource();
  DebugReportRunner.execGraphics2D( resource );
  DebugReportRunner.execGraphics2D( resource );
  DebugReportRunner.execGraphics2D( resource );

  TestCacheBackend cacheInstance = (TestCacheBackend) DataCacheFactory.getCache();
  Assert.assertEquals( 1, cacheInstance.getCache().size() );
  Assert.assertEquals( 1, cacheInstance.putCount );
  Assert.assertEquals( 3, cacheInstance.getCount );
}
 
Example 8
/**
 * Reads the report from the specified template file.
 *
 * @param templateURL the template location.
 * @return a report.
 * @throws ParseException if the report could not be parsed.
 */
private MasterReport parseReport(final URL templateURL)
    throws ParseException
{
  try
  {
    final ResourceManager mgr = new ResourceManager();
    final Resource resource = mgr.createDirectly(templateURL, MasterReport.class);
    final MasterReport report = (MasterReport) resource.getResource();
    final URL imageURL = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/gorilla.jpg", StraightToPDF.class);
    final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    report.getParameterValues().put("logo", image);

    return report;
  }
  catch (Exception e)
  {
    throw new ParseException("Failed to parse the report", e);
  }
}
 
Example 9
/**
 * Starts parsing.
 *
 * @param attrs
 *          the attributes.
 * @throws SAXException
 *           if there is a parsing error.
 */
protected void startParsing( final Attributes attrs ) throws SAXException {
  super.startParsing( attrs );

  final ResourceManager resourceManager = getRootHandler().getResourceManager();
  final ResourceKey context = getRootHandler().getContext();

  final Configuration configuration = ClassicEngineBoot.getInstance().getGlobalConfig();
  final Iterator keys = configuration.findPropertyKeys( ElementMetaDataParser.GLOBAL_INCLUDES_PREFIX );
  while ( keys.hasNext() ) {
    final String key = (String) keys.next();
    final String href = configuration.getConfigProperty( key );
    if ( StringUtils.isEmpty( href, true ) ) {
      continue;
    }

    try {
      final ResourceKey resourceKey = resourceManager.deriveKey( context, href );
      final Resource resource = resourceManager.create( resourceKey, null, GlobalMetaDefinition.class );
      globalMetaDefinition.merge( (GlobalMetaDefinition) resource.getResource() );
    } catch ( ResourceException e ) {
      logger.warn( "Failed to parse included global definitions: " + getLocator(), e );
    }
  }

}
 
Example 10
public DataSchema getDataSchema() {
  if ( dataSchema == null ) {
    final ParameterDataRow parameterRow = computeParameterData();
    final ParameterDefinitionEntry[] parameterDefinitions = computeParameterDefinitionEntries();

    final ResourceManager resourceManager = getMasterReportElement().getResourceManager();
    final DataSchemaCompiler dataSchemaCompiler =
      new DataSchemaCompiler( getDataSchemaDefinition(), getDataAttributeContext(), resourceManager );

    try {
      final TableModel reportData = new DefaultTableModel();
      final Expression[] expressions = getReport().getExpressions().getExpressions();
      final ReportEnvironment reportEnvironment = getMasterReportElement().getReportEnvironment();
      dataSchema = dataSchemaCompiler.compile
        ( reportData, expressions, parameterRow, parameterDefinitions, reportEnvironment );

    } catch ( final ReportDataFactoryException e ) {
      dataSchema = new DefaultDataSchema();
    }
  }

  return dataSchema;
}
 
Example 11
public void testReport() throws ResourceException {
  final URL url = getClass().getResource( "Prd-3245.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  DebugReportRunner.execGraphics2D( report );

  if ( GraphicsEnvironment.isHeadless() ) {
    return;
  }

  final PreviewDialog previewDialog = new PreviewDialog( report );
  previewDialog.pack();
  previewDialog.setModal( true );
  previewDialog.setVisible( true );
}
 
Example 12
public void testDialog() throws Exception {
  if ( GraphicsEnvironment.isHeadless() ) {
    return;
  }

  final URL url = getClass().getResource( "Prd-3620-small.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();

  final PreviewDialog dialog = new PreviewDialog( report );
  dialog.setModal( true );
  dialog.pack();
  dialog.setVisible( true );
}
 
Example 13
/**
 * Reads the report from the specified template file.
 *
 * @param templateURL the template location.
 * @return a report.
 * @throws ParseException if the report could not be parsed.
 */
private MasterReport parseReport(final URL templateURL)
    throws ParseException
{
  try
  {
    final ResourceManager mgr = new ResourceManager();
    final Resource resource = mgr.createDirectly(templateURL, MasterReport.class);
    final MasterReport report = (MasterReport) resource.getResource();
    // this demo adds the image at runtime just to show how this could be
    // done. Usually such images get referenced from the XML itself without
    // using manual coding.
    final URL imageURL = ObjectUtilities.getResource
        ("org/pentaho/reporting/engine/classic/demo/opensource/gorilla.jpg", StraightToPNG.class);
    final Image image = Toolkit.getDefaultToolkit().createImage(imageURL);
    final WaitingImageObserver obs = new WaitingImageObserver(image);
    obs.waitImageLoaded();
    report.getParameterValues().put("logo", image);
    return report;
  }
  catch (Exception e)
  {
    throw new ParseException("Failed to parse the report", e);
  }
}
 
Example 14
/**
 * This is a happy path "round-trip" test which should demonstrate the serializing and deserializing a resource key
 * should produce the same key
 */
public void testSerializeDeserializeRoundtrip() throws Exception {
  final URLResourceLoader resourceLoader = new URLResourceLoader();
  final Map<ParameterKey, Object> factoryParams = new HashMap<ParameterKey, Object>();
  final ResourceManager manager = new ResourceManager();
  manager.registerDefaults();

  factoryParams.put( new FactoryParameterKey( "this" ), "that" );
  factoryParams.put( new FactoryParameterKey( "null" ), null );
  final ResourceKey originalKey = manager.createKey( URL1, factoryParams );

  final String serializedVersion = resourceLoader.serialize( null, originalKey );
  final ResourceKey duplicateKey = resourceLoader.deserialize( null, serializedVersion );
  assertNotNull( duplicateKey );
  assertTrue( originalKey.equals( duplicateKey ) );
}
 
Example 15
@Test
public void testTxt() throws ResourceException {
  URL url = getClass().getResource( "BACKLOG-6818.prpt" );

  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();

  try ( ByteArrayOutputStream stream = new ByteArrayOutputStream() ) {
    PlainTextReportUtil.createPlainText( report, stream );
    final byte[] bytes = stream.toByteArray();
    assertNotNull( bytes );
    assertTrue( bytes.length > 0 );
    assertTrue( StringUtils.isNotBlank( new String( bytes, "UTF-8" ) ) );
  } catch ( final IOException | ReportProcessingException e ) {
    fail();
  }
}
 
Example 16
@Test
public void testSampleReport() throws Exception {
  URL res = getClass().getResource( "Prd-4965.prpt" );
  MasterReport report = (MasterReport) new ResourceManager().createDirectly( res, MasterReport.class ).getResource();
  LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage( report, 0 );
  RenderNode[] mrs = MatchFactory.findElementsByName( logicalPageBox, "mr" );
  Assert.assertEquals( 2, mrs.length );
  Assert.assertTrue( mrs[0] instanceof ParagraphRenderBox );
  Assert.assertTrue( mrs[1] instanceof RenderableText );

  RenderNode[] sr0s = MatchFactory.findElementsByName( logicalPageBox, "sr-1" );
  Assert.assertEquals( 2, sr0s.length );
  Assert.assertTrue( sr0s[0] instanceof ParagraphRenderBox );
  Assert.assertTrue( sr0s[1] instanceof RenderableText );

  RenderNode[] sr1s = MatchFactory.findElementsByName( logicalPageBox, "sr-2" );
  Assert.assertEquals( 2, sr1s.length );
  Assert.assertTrue( sr1s[0] instanceof ParagraphRenderBox );
  Assert.assertTrue( sr1s[1] instanceof RenderableText );

}
 
Example 17
public static ResourceKey createURI( final String uri, final DocumentContext layoutProcess ) {
  try {
    final ResourceKey base = layoutProcess.getContextKey();
    final ResourceManager resourceManager =
      layoutProcess.getResourceManager();

    if ( base != null ) {
      try {
        return resourceManager.deriveKey( base, uri );
      } catch ( ResourceKeyCreationException ex ) {
        // ignore ..
      }
    }
    return resourceManager.createKey( uri );
  } catch ( Exception e ) {
    return null;
  }
}
 
Example 18
public void testSubreportPageHeader() throws Exception {
  // right now, this ends in a infinite loop. Not funny ..
  final URL url = getClass().getResource( "subreport-pageheader.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport resource = (MasterReport) directly.getResource();

  DebugReportRunner.executeAll( resource );
  // subreports in the page-header must be handled gracefully.
}
 
Example 19
public int canHandleResource( final ResourceManager caller, final ResourceData data )
  throws ResourceCreationException, ResourceLoadingException {
  if ( parent == null ) {
    return FactoryModule.REJECTED;
  }
  return parent.canHandleResource( caller, data );
}
 
Example 20
/**
 * @param outputProcessorMetaData
 * @param resourceBundleFactory
 * @param configuration
 * @param resourceManager
 * @param contentBase
 *          the content base, from where to load additional resources. (Can be null).
 * @param metaData
 */
public DefaultProcessingContext( final OutputProcessorMetaData outputProcessorMetaData,
    final ResourceBundleFactory resourceBundleFactory, final Configuration configuration,
    final ResourceManager resourceManager, final ResourceKey contentBase, final DocumentMetaData metaData,
    final ReportEnvironment environment, final int compatibilityLevel ) throws ReportProcessingException {
  if ( environment == null ) {
    throw new NullPointerException();
  }
  if ( configuration == null ) {
    throw new NullPointerException();
  }
  if ( outputProcessorMetaData == null ) {
    throw new NullPointerException();
  }
  if ( resourceBundleFactory == null ) {
    throw new NullPointerException();
  }
  if ( resourceManager == null ) {
    throw new NullPointerException();
  }

  this.contentBase = contentBase;
  this.resourceManager = resourceManager;
  this.outputProcessorMetaData = outputProcessorMetaData;
  this.resourceBundleFactory = MasterReport.computeAndInitResourceBundleFactory( resourceBundleFactory, environment );
  this.formulaContext =
      DefaultFormulaContextFactory.INSTANCE.create( resourceBundleFactory.getLocale(), resourceBundleFactory
          .getTimeZone() );
  this.configuration = configuration;
  if ( metaData == null ) {
    this.metaData = new MemoryDocumentMetaData();
  } else {
    this.metaData = metaData;
  }
  this.reportEnvironment = new CachingReportEnvironment( environment );
  this.startTime = System.currentTimeMillis();
  this.compatibilityLevel = compatibilityLevel;
}
 
Example 21
public int canHandleResource( final ResourceManager caller, final ResourceData data )
  throws ResourceCreationException, ResourceLoadingException {
  try {
    final byte[] resource = data.getResource( caller );
    if ( createImage( resource ) != null ) {
      return RECOGNIZED_CONTENTTYPE;
    }
  } catch ( IOException e ) {
    // ignore me ..
  }
  return REJECTED;
}
 
Example 22
public void testFromBundle() throws Exception {

    final ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    final Resource res =
      manager.createDirectly( XPathQueryTest.class.getResource( "xpath-bundle-test.prpt" ), MasterReport.class );
    final MasterReport report = (MasterReport) res.getResource();

    final CompoundDataFactory dataFactory = (CompoundDataFactory) report.getDataFactory();
    final XPathDataFactory xpathDataFactory = (XPathDataFactory) dataFactory.getReference( 0 );
    xpathDataFactory.initialize( new DesignTimeDataFactoryContext( report ) );
    xpathDataFactory.queryData( "default", new StaticDataRow() );
    xpathDataFactory.close();
  }
 
Example 23
@Test
public void testIsLimitNotReachedForNumberOfRowsLessQueryLimit() throws Exception {
  //When data source enforce limit itself
  // report with 148 rows
  final URL url = getClass().getResource( "report1.prpt" );
  assertNotNull( url );
  final ResourceManager resourceManager = new ResourceManager();
  resourceManager.registerDefaults();
  final Resource directly = resourceManager.createDirectly( url, MasterReport.class );
  final MasterReport report = (MasterReport) directly.getResource();
  report.setQueryLimit( 149 );
  final AbstractReportProcessor reportProcessor = new DummyReportProcessor( report );
  reportProcessor.prepareReportProcessing();
  assertEquals( reportProcessor.isQueryLimitReached(), false );
}
 
Example 24
public static MasterReport loadReport( final Object selectedFile, final ResourceManager resourceManager )
  throws ResourceException, IOException {
  final Resource directly = resourceManager.createDirectly( selectedFile, MasterReport.class );
  final MasterReport resource = (MasterReport) directly.getResource();
  final DocumentBundle bundle = resource.getBundle();
  if ( bundle == null ) {
    // Ok, that should not happen if we work with the engine's parsers, but better safe than sorry.
    final MemoryDocumentBundle documentBundle = new MemoryDocumentBundle( resource.getContentBase() );
    documentBundle.getWriteableDocumentMetaData().setBundleType( ClassicEngineBoot.BUNDLE_TYPE );
    resource.setBundle( documentBundle );
    resource.setContentBase( documentBundle.getBundleMainKey() );
  } else {
    final MemoryDocumentBundle mem = new MemoryDocumentBundle( resource.getContentBase() );
    BundleUtilities.copyStickyInto( mem, bundle );
    BundleUtilities.copyMetaData( mem, bundle );
    resource.setBundle( mem );
    resource.setContentBase( mem.getBundleMainKey() );
  }

  final Object visible =
    resource.getBundle().getMetaData().getBundleAttribute( ClassicEngineBoot.METADATA_NAMESPACE, "visible" );//NON-NLS
  if ( "true".equals( visible ) )//NON-NLS
  {
    resource.setAttribute( AttributeNames.Pentaho.NAMESPACE, "visible", Boolean.TRUE );//NON-NLS
  } else if ( "false".equals( visible ) )//NON-NLS
  {
    resource.setAttribute( AttributeNames.Pentaho.NAMESPACE, "visible", Boolean.FALSE );//NON-NLS
  }
  return resource;
}
 
Example 25
public void initialize() {
  try {
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    final Resource resource = resourceManager.createDirectly( "res://fonts.xml", FontMetricsCollection.class );
    this.fontMetricsCollection = (FontMetricsCollection) resource.getResource();
  } catch ( ResourceException e ) {
    throw new IllegalStateException( e );
  }
}
 
Example 26
public void testBugExists() throws Exception {
  final URL resource = getClass().getResource( "Prd-4653.prpt" );
  assertNotNull( resource );

  final ResourceManager mgr = new ResourceManager();
  mgr.registerDefaults();
  final Resource parsed = mgr.createDirectly( resource, MasterReport.class );
  final MasterReport report = (MasterReport) parsed.getResource();
  report.getRootGroup().getElement( 0 ).setName( "master-group-header" );

  final LogicalPageBox page = DebugReportRunner.layoutPage( report, 1 );
  final RenderNode[] elementsByName = MatchFactory.findElementsByName( page, "master-group-header" );

  assertEquals( 1, elementsByName.length );
}
 
Example 27
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException {
  final InputStream stream = ObjectUtilities.getResourceAsStream
    ( resourcePath, ClassloaderResourceData.class );
  if ( stream == null ) {
    throw new ResourceLoadingException( "Resource is not available: " + resourcePath );
  }
  return stream;
}
 
Example 28
@Test
public void testFrom52() throws Exception {
  URL url = getClass().getResource( "Prd-5245-from52.prpt" );
  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();
  final ByteArrayOutputStream boutFast = new ByteArrayOutputStream();
  final ByteArrayOutputStream boutSlow = new ByteArrayOutputStream();
  FastHtmlReportUtil.processStreamHtml( report, boutFast );
  HtmlReportUtil.createStreamHTML( report, boutSlow );
  String htmlFast = boutFast.toString( "UTF-8" );
  String htmlSlow = boutSlow.toString( "UTF-8" );
  Assert.assertEquals( htmlSlow, htmlFast );
}
 
Example 29
@Test
public void testIndention() throws ResourceException, IOException, ReportProcessingException {
  URL url = getClass().getResource( "Prd-5522.prpt" );
  MasterReport report = (MasterReport) new ResourceManager().createDirectly( url, MasterReport.class ).getResource();
  org.pentaho.reporting.engine.classic.core.testsupport.DebugReportRunner.createTestOutputFile();
  ExcelReportUtil.createXLSX( report, "test-output/Prd-5522.xlsx" );
  ;
}
 
Example 30
protected MasterReport postProcess( final MasterReport originalReport ) throws Exception {
  final MemoryByteArrayOutputStream bout = new MemoryByteArrayOutputStream();
  BundleWriter.writeReportToZipStream( originalReport, bout );
  assertTrue( bout.getLength() > 0 );
  /*
   * final File f = File.createTempFile("test-output-", ".prpt", new File ("test-output")); final FileOutputStream
   * outputStream = new FileOutputStream(f); outputStream.write(bout.toByteArray()); outputStream.close();
   */
  final ResourceManager mgr = new ResourceManager();
  final Resource reportRes = mgr.createDirectly( bout.toByteArray(), MasterReport.class );
  return (MasterReport) reportRes.getResource();
}