Package org.pentaho.reporting.libraries.resourceloader

Examples of org.pentaho.reporting.libraries.resourceloader.ResourceManager


  }

  public static MasterReport loadReport(final File selectedFile)
      throws ResourceException, IOException
  {
    final ResourceManager resourceManager = new ResourceManager();
    final MasterReport reportDefinition = loadReport(selectedFile, resourceManager);
    try
    {
      reportDefinition.setAttribute
          (ReportDesignerBoot.DESIGNER_NAMESPACE, "report-save-path", selectedFile.getCanonicalPath()); // NON-NLS
View Full Code Here


  }

  public void testItemBandLayout() throws ResourceException, ReportProcessingException, ContentProcessingException
  {
    final URL url = ReportLayouterTest.class.getResource("Prd-4109.prpt");
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    final Resource resource = resourceManager.createDirectly(url, MasterReport.class);
    final MasterReport report = (MasterReport) resource.getResource();

    final ReportLayouter l = new ReportLayouter
        (new ReportRenderContext(report, report, null, new GlobalAuthenticationStore()));
    final LogicalPageBox layout = l.layout();
View Full Code Here

  public void testBug () throws Exception
  {
    final URL resource = getClass().getResource("Prd-4642.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 masterContext =
        new ReportRenderContext(report, report, null, globalAuthenticationStore);
    final SubReport subReport = (SubReport) report.getReportHeader().getElement(1);
View Full Code Here

  public void testHtmlExportFull () throws Exception
  {
    final URL url = getClass().getResource("Prd-3931.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.setCompatibilityLevel(null);
    report.getReportConfiguration().setConfigProperty(ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "false");

    final Group rootGroup = report.getRootGroup();
View Full Code Here

  public void testHtmlExportFullComplexText () throws Exception
  {
    final URL url = getClass().getResource("Prd-3931.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.setCompatibilityLevel(null);
    report.getReportConfiguration().setConfigProperty(ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "true");

    final Group rootGroup = report.getRootGroup();
View Full Code Here

  public void testExportToXml () throws Exception
  {
    final URL url = getClass().getResource("Prd-3931.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.setCompatibilityLevel(ClassicEngineBoot.computeVersionId(4, 0, 0));

    final LogicalPageBox pageBox = DebugReportRunner.layoutPage(report, 0);
  //  ModelPrinter.INSTANCE.print(pageBox);
View Full Code Here

  {
    final File file = new File (textField.getText());

    try
    {
      ResourceManager manager = new ResourceManager();
      Resource res = manager.createDirectly(file, MasterReport.class);
      return (MasterReport) res.getResource();
    }
    catch (Exception e)
    {
      throw new ReportDefinitionException("Parsing failed", e);
View Full Code Here

   * Tests the serialization of File based resource keys
   */
  public void testSerialize() throws Exception
  {
    final FileResourceLoader fileResourceLoader = new FileResourceLoader();
    final ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    ResourceKey key = null;
    Map<ParameterKey, Object> factoryParameters = new HashMap<ParameterKey, Object>();
    String serializedVersion = null;

    // Test with null parameter
    try
    {
      serializedVersion = fileResourceLoader.serialize(null, key);
      fail("Serialization with a null paramter should throw a NullPointerException"); //$NON-NLS-1$
    }
    catch (NullPointerException npe)
    {
      // success
    }

    // Test with a resource key instead of a file key
    try
    {
      key = manager.createKey("res://org/pentaho/reporting/libraries/resourceloader/test1.properties"); //$NON-NLS-1$
      serializedVersion = fileResourceLoader.serialize(key, key);
      fail("The resource key should not handles by the file resource loader"); //$NON-NLS-1$
    }
    catch (IllegalArgumentException iae)
    {
      // success
    }

    // Create a key from the temp file
    key = manager.createKey(tempFile);
    serializedVersion = fileResourceLoader.serialize(key, key);
    assertNotNull("The returned key should not be null", key); //$NON-NLS-1$
    assertTrue("Serialized verison does not start with the correct header", serializedVersion //$NON-NLS-1$
        .startsWith(STRING_SERIALIZATION_PREFIX));
    assertTrue("Serialized version does not contain the correct schema information", serializedVersion //$NON-NLS-1$
        .startsWith(STRING_SERIALIZATION_PREFIX + fileResourceLoader.getClass().getName() + ';'));
    assertTrue("Serialized version should contain the filename", serializedVersion.endsWith(tempFile.getName())); //$NON-NLS-1$

    // Create a key as a relative path from the above key
    key = manager.deriveKey(key, tempRelativeFilename);
    assertNotNull(key);
    serializedVersion = fileResourceLoader.serialize(key, key);
    assertNotNull(serializedVersion);
    assertTrue("Serialized verison does not start with the correct header", serializedVersion //$NON-NLS-1$
        .startsWith(STRING_SERIALIZATION_PREFIX));
    assertTrue("Serialized version does not contain the correct schema information", serializedVersion //$NON-NLS-1$
        .startsWith(STRING_SERIALIZATION_PREFIX + fileResourceLoader.getClass().getName() + ';'));
    assertTrue(
        "Serialized version should contain the filename", serializedVersion.endsWith(tempSubFile.getCanonicalPath())); //$NON-NLS-1$

    // Create a key with factory parameters
    factoryParameters.put(new FactoryParameterKey("this"), "that");
    factoryParameters.put(new FactoryParameterKey("null"), null);
    key = manager.createKey(tempFile, factoryParameters);
    serializedVersion = fileResourceLoader.serialize(key, key);

    assertNotNull("The returned key should not be null", key); //$NON-NLS-1$
    assertTrue("Serialized verison does not start with the correct header", serializedVersion //$NON-NLS-1$
        .startsWith(STRING_SERIALIZATION_PREFIX));
View Full Code Here

   */
  public void testSerializeDeserializeRoundtrip() throws Exception
  {
    final FileResourceLoader fileResourceLoader = new FileResourceLoader();
    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(tempFile, factoryParams);
   
    final String serializedVersion = fileResourceLoader.serialize(null, originalKey);
    final ResourceKey duplicateKey = fileResourceLoader.deserialize(null, serializedVersion);
    assertNotNull(duplicateKey);
    assertTrue(originalKey.equals(duplicateKey));
View Full Code Here

  }

  public void testSerialize() throws Exception
  {
    final ResourceLoader resourceLoader = new ClassloaderResourceLoader();
    final ResourceManager manager = new ResourceManager();
    manager.registerDefaults();

    // Test failure - null key
    try
    {
      resourceLoader.serialize(null, null);
      fail("Serialization of a null key should throw an exception");
    }
    catch (NullPointerException npe)
    {
      // success
    }
   
    // Test failure - not a Classloader resource key
    try
    {
      final File tempFile = File.createTempFile("junit-test", ".tmp");
      final ResourceKey tempKey = manager.createKey(tempFile);
      resourceLoader.serialize(null, tempKey);
      fail("The Classloader Resource Loader should fail when handling a non-classloader resource key");
    }
    catch(IllegalArgumentException iae)
    {
      // success
    }

    // Create key
    final String key1source = "res://org/pentaho/reporting/libraries/resourceloader/test1.properties";
    final ResourceKey key1 = manager.createKey(key1source);
    assertNotNull(key1);

    // Serialize the key
    final String serKey1 = resourceLoader.serialize(null, key1);
    assertNotNull("The returned key should not be null", serKey1); //$NON-NLS-1$
    assertTrue("Serialized verison does not start with the correct header", serKey1.startsWith(STRING_SERIALIZATION_PREFIX));
    assertTrue("Serialized version does not contain the correct schema information", serKey1.startsWith(DESERIALIZE_PREFIX));
    assertTrue("Serialized version should contain the identifier intact", serKey1.endsWith(key1.getIdentifier().toString()));

    // Serialize a key created from a derived key
    final String key2source = "test2.properties";
    final ResourceKey key2 = manager.deriveKey(key1, key2source);
    assertNotNull(key2);

    final String serKey2 = resourceLoader.serialize(null, key2);
    assertNotNull("The returned key should not be null", serKey2); //$NON-NLS-1$
    assertTrue("Serialized verison does not start with the correct header", serKey2.startsWith(STRING_SERIALIZATION_PREFIX));
    assertTrue("Serialized version does not contain the correct schema information", serKey2.startsWith(DESERIALIZE_PREFIX));
    assertTrue("Serialized version should contain the identifier intact", serKey2.endsWith(";res://org/pentaho/reporting/libraries/resourceloader/test2.properties"));

    // Serialize a key with factory parameters
    final Map<ParameterKey, Object> factoryParams = new HashMap<ParameterKey, Object>();
    factoryParams.put(new FactoryParameterKey("this"), "that");
    factoryParams.put(new FactoryParameterKey("null"), null);
    final ResourceKey key3 = manager.createKey(key1source, factoryParams);
    assertNotNull(key3);

    final String serKey3 = resourceLoader.serialize(null, key3);
    assertEquals("resourcekey:org.pentaho.reporting.libraries.resourceloader" +
        ".loader.resource.ClassloaderResourceLoader;" +
View Full Code Here

TOP

Related Classes of org.pentaho.reporting.libraries.resourceloader.ResourceManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.