Пример #1
0
  @Test
  public void testTableColumns() throws Exception {
    final MasterReport report = DebugReportRunner.parseGoldenSampleReport("Prd-4523.prpt");
    report
        .getReportConfiguration()
        .setConfigProperty(ClassicEngineCoreModule.COMPLEX_TEXT_CONFIG_OVERRIDE_KEY, "false");
    LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 0);
    RenderNode[] elementsByNodeType =
        MatchFactory.findElementsByNodeType(logicalPageBox, LayoutNodeTypes.TYPE_BOX_TABLE);
    assertEquals(1, elementsByNodeType.length);
    TableRenderBox table = (TableRenderBox) elementsByNodeType[0];
    long width = table.getWidth();
    DebugLog.log(width);
    SeparateColumnModel columnModel = (SeparateColumnModel) table.getColumnModel();
    long sum = 0;
    final ArrayList<TableColumn> expected = new ArrayList<TableColumn>();
    expected.add(createTableColumn(4748666, 4222000, 0, 0, 0));
    expected.add(createTableColumn(4694666, 4168000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 2824000));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 2824000));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 2824000, 0, 0));
    expected.add(createTableColumn(8415666, 7889000, 0, 0, 0));

    TableColumn[] columns = columnModel.getColumns();
    for (int i = 0; i < columns.length; i += 1) {
      TableColumn c = columnModel.getColumn(i);
      assertColumnsEqual(expected.get(i), c);
    }
  }
  public void testStandardReport2() throws Exception {
    if (DebugReportRunner.isSkipLongRunTest()) {
      return;
    }

    final MasterReport report = DebugReportRunner.parseGoldenSampleReport("Prd-3857-001.prpt");
    final Group rootGroup = report.getRootGroup();
    assertTrue(rootGroup instanceof CrosstabGroup);

    final CrosstabGroup ct = (CrosstabGroup) rootGroup;
    ct.setPrintColumnTitleHeader(false);
    ct.setPrintDetailsHeader(false);

    // Prints two header rows, and 21 data rows (row 0 to row 20)
    List<LogicalPageBox> logicalPageBoxes = DebugReportRunner.layoutPages(report, 0, 1);
    final LogicalPageBox boxP1 = logicalPageBoxes.get(0);
    // ModelPrinter.INSTANCE.print(boxP1);
    final RenderNode[] rowsPage1 =
        MatchFactory.findElementsByNodeType(boxP1, LayoutNodeTypes.TYPE_BOX_TABLE_ROW);
    assertEquals(23, rowsPage1.length);

    // Prints two header rows and 7 data rows (row 21 to row 27)
    final LogicalPageBox boxP2 = logicalPageBoxes.get(1);
    // ModelPrinter.INSTANCE.print(boxP2);
    final RenderNode[] rowsPage2 =
        MatchFactory.findElementsByNodeType(boxP2, LayoutNodeTypes.TYPE_BOX_TABLE_ROW);
    assertEquals(9, rowsPage2.length);
  }
Пример #3
0
 public void testWidow1Error() throws Exception {
   final MasterReport masterReport =
       DebugReportRunner.parseGoldenSampleReport("Prd-2087-Widow-1.prpt");
   // masterReport.setCompatibilityLevel(ClassicEngineBoot.computeVersionId(3, 8, 0));
   //    DebugReportRunner.createXmlTablePageable(masterReport);
   final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(masterReport, 3);
   //    ModelPrinter.INSTANCE.print(logicalPageBox);
 }
Пример #4
0
 public void testSeq1Crash2() throws Exception {
   if (DebugReportRunner.isSkipLongRunTest()) {
     return;
   }
   final MasterReport masterReport =
       DebugReportRunner.parseGoldenSampleReport("Prd-2087-small.prpt");
   DebugReportRunner.createPDF(masterReport);
 }
Пример #5
0
  public void testWidow2Crash2() throws Exception {
    final MasterReport masterReport =
        DebugReportRunner.parseGoldenSampleReport("Prd-2087-Widow-2.prpt");
    // masterReport.setCompatibilityLevel(ClassicEngineBoot.computeVersionId(3, 8, 0));
    DebugReportRunner.createXmlPageable(masterReport);

    //    DebugReportRunner.showDialog(masterReport);

  }
Пример #6
0
  public void testOrphan4() throws Exception {
    final MasterReport masterReport =
        DebugReportRunner.parseGoldenSampleReport("Prd-2087-Orphan-4.prpt");

    final LogicalPageBox box = DebugReportRunner.layoutPage(masterReport, 0);
    final RenderNode srs[] = MatchFactory.findElementsByElementType(box, SubReportType.INSTANCE);
    assertEquals(1, srs.length);
    assertEquals(StrictGeomUtility.toInternalValue(20), srs[0].getY());
    final RenderNode elementByName = MatchFactory.findElementByName(box, "outer-group");
    assertEquals(StrictGeomUtility.toInternalValue(20), elementByName.getY());
  }
Пример #7
0
  /**
   * Canvas elements do not shift content. Therefore the widow definition is not effective.
   *
   * @throws Exception
   */
  public void testOrphan5() throws Exception {
    final MasterReport masterReport =
        DebugReportRunner.parseGoldenSampleReport("Prd-2087-Orphan-5.prpt");
    // masterReport.setCompatibilityLevel(ClassicEngineBoot.computeVersionId(3, 8, 0));
    // DebugReportRunner.createXmlPageable(masterReport);

    final LogicalPageBox box = DebugReportRunner.layoutPage(masterReport, 0);
    final RenderNode elementByName = MatchFactory.findElementByName(box, "outer-group");
    assertEquals(StrictGeomUtility.toInternalValue(20), elementByName.getY());
    //    ModelPrinter.INSTANCE.print(box);
    //    DebugReportRunner.showDialog(masterReport);

  }
  @Test
  public void testCanvasWithPrePostPad() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, new CustomProducer());
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 200f);
    table.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 100f);
    table.getStyle().setStyleProperty(ElementStyleKeys.POS_Y, 10f);
    table.setName("table");
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Pre-Padding", 100, 10));
    report.getReportHeader().addElement(table);

    Element postPaddingItem = TableTestUtil.createDataItem("Post-Padding", 100, 10);
    postPaddingItem.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 300f);
    report.getReportHeader().addElement(postPaddingItem);
    report.getReportHeader().setLayout("canvas");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-output-canvas.pdf");

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);
    assertPageValid(pages, 0, StrictGeomUtility.toInternalValue(10));
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
  }
  public void testErrorHandlingBad() throws Exception {
    final URL url = getClass().getResource("Prd-3985.prpt");
    final ResourceManager mgr = new ResourceManager();
    final MasterReport report =
        (MasterReport) mgr.createDirectly(url, MasterReport.class).getResource();
    report
        .getReportConfiguration()
        .setConfigProperty(
            "org.pentaho.reporting.engine.classic.core.FailOnAttributeExpressionErrors", "true");

    final FormulaExpression function = new FormulaExpression();
    function.setName("Test");
    function.setFormula("=MULTIVALUEQUERY(\"Bad\")");

    report
        .getReportHeader()
        .setAttributeExpression(AttributeNames.Core.NAMESPACE, AttributeNames.Core.NAME, function);

    try {
      DebugReportRunner.createPDF(report);
      Assert.fail();
    } catch (Exception e) {
      // ignored
    }
  }
  public void testRowBoxesEstablishOwnBlockContext() throws Exception {
    // this report defines that the group as well as all bands within that group are row-layout.
    // therefore the two itembands end on the same row.

    // The itemband did not define a width, not even a 100% width, and thus ends with a width of
    // auto/zero.
    // therefore the itemband shrinks to the minimal size that still encloses all elements.
    // the elements that have percentage width are resolved against the block context.
    // A band without a width defined (the itemband!), does not establish an own block-context, so
    // it
    // takes the block context of the parent, or as fallback: page.

    final File file = GoldTestBase.locateGoldenSampleReport("Prd-3479.prpt");
    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource directly = mgr.createDirectly(file, MasterReport.class);
    final MasterReport report = (MasterReport) directly.getResource();
    report.setCompatibilityLevel(null);

    final LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 0);
    final RenderNode[] itembands =
        MatchFactory.findElementsByElementType(logicalPageBox, ItemBandType.INSTANCE);

    assertEquals(2, itembands.length);
    assertEquals(48208843, itembands[0].getWidth());
    assertEquals(48208843, itembands[1].getWidth());
    assertEquals(48208843, itembands[1].getX());
  }
  @Test
  public void testXlsFastListener() throws Exception {
    URL url = getClass().getResource("BACKLOG-7181.prpt");
    MasterReport report =
        (MasterReport) new ResourceManager().createDirectly(url, MasterReport.class).getResource();
    org.pentaho.reporting.engine.classic.core.testsupport.DebugReportRunner.createTestOutputFile();
    final ReportProgressListener mock = mock(ReportProgressListener.class);
    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
      FastExcelReportUtil.processXls(report, stream, mock);
      final byte[] bytes = stream.toByteArray();
      Assert.assertNotNull(bytes);
      Assert.assertTrue(bytes.length > 0);
    }

    verify(mock, times(1)).reportProcessingStarted(any(ReportProgressEvent.class));
    verify(mock, times(1)).reportProcessingFinished(any(ReportProgressEvent.class));
    verify(mock, atLeastOnce()).reportProcessingUpdate(any(ReportProgressEvent.class));

    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
      FastExcelReportUtil.processXls(new MasterReport(), stream, mock);
    }

    verify(mock, times(2)).reportProcessingStarted(any(ReportProgressEvent.class));
    verify(mock, times(2)).reportProcessingFinished(any(ReportProgressEvent.class));
  }
  public void testMissingTableRow() throws ReportProcessingException, ContentProcessingException {
    final Band tableBody = new Band();
    tableBody.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE_BODY);
    tableBody.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, -100f);
    tableBody.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 200f);

    final Band table = new Band();
    table.getStyle().setStyleProperty(BandStyleKeys.LAYOUT, BandStyleKeys.LAYOUT_TABLE);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, -100f);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 200f);
    table.addElement(TableTestUtil.createAutoBox(tableBody));

    final MasterReport report = new MasterReport();
    final ReportHeader band = report.getReportHeader();
    band.addElement(table);

    final LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, band, false, false);
    // ModelPrinter.print(logicalPageBox);

    final DescendantMatcher matcher =
        new DescendantMatcher(new ElementMatcher("TableCellRenderBox"));
    final RenderNode[] all = MatchFactory.matchAll(logicalPageBox, matcher);

    assertEquals(0, all.length);
  }
 @Test
 public void testExecuteReports() throws Exception {
   if (DebugReportRunner.isSkipLongRunTest()) {
     return;
   }
   runAllGoldReports();
 }
 @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");
   ;
 }
  public void testPagebreakHonoredOnFirstPage() throws Exception {
    final MasterReport masterReport = DebugReportRunner.parseGoldenSampleReport("Pre-492.prpt");
    final LogicalPageBox page0 = DebugReportRunner.layoutPage(masterReport, 0);
    final RenderNode[] elementsByElementType =
        MatchFactory.findElementsByElementType(page0.getContentArea(), AutoLayoutBoxType.INSTANCE);
    assertEquals(31, elementsByElementType.length);
    assertEquals(
        StrictGeomUtility.toInternalValue(199),
        elementsByElementType[elementsByElementType.length - 1].getY());

    final LogicalPageBox page1 = DebugReportRunner.layoutPage(masterReport, 1);
    final RenderNode[] elementsPage1 =
        MatchFactory.findElementsByElementType(page1.getContentArea(), AutoLayoutBoxType.INSTANCE);
    assertEquals(34, elementsPage1.length);
    assertEquals(
        StrictGeomUtility.toInternalValue(211), elementsPage1[elementsPage1.length - 1].getY());
    //  ModelPrinter.INSTANCE.print(page1);
  }
 @Test
 public void testXlsxFast() throws Exception {
   org.pentaho.reporting.engine.classic.core.testsupport.DebugReportRunner.createTestOutputFile();
   try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
     FastExcelReportUtil.processXlsx(new MasterReport(), stream);
     final byte[] bytes = stream.toByteArray();
     Assert.assertNotNull(bytes);
     Assert.assertTrue(bytes.length > 0);
   }
 }
  public void testGoldRun() throws Exception {
    final File file = GoldTestBase.locateGoldenSampleReport("Prd-3239.prpt");
    final ResourceManager mgr = new ResourceManager();
    mgr.registerDefaults();
    final Resource directly = mgr.createDirectly(file, MasterReport.class);
    final MasterReport report = (MasterReport) directly.getResource();
    report.setCompatibilityLevel(ClassicEngineBoot.computeVersionId(3, 8, 0));

    DebugReportRunner.createXmlFlow(report);
  }
Пример #18
0
 @Test
 public void testComplexCrosstab() throws ResourceException, ReportProcessingException {
   final MasterReport report = DebugReportRunner.parseGoldenSampleReport("Prd-4523.prpt");
   report
       .getReportConfiguration()
       .setConfigProperty(
           "org.pentaho.reporting.engine.classic.core.modules.output.table.base.FailOnCellConflicts",
           "true");
   HtmlReportUtil.createStreamHTML(report, new NullOutputStream());
 }
  public void testRichText() throws ReportProcessingException, ContentProcessingException {
    final Element e = new Element();
    e.setElementType(LabelType.INSTANCE);
    e.setAttribute(AttributeNames.Core.NAMESPACE, AttributeNames.Core.RICH_TEXT_TYPE, "text/html");
    e.setAttribute(
        AttributeNames.Core.NAMESPACE,
        AttributeNames.Core.VALUE,
        "Hi I am trying to use the <b>rich text type = text/html</b> in PRD version - 3.7.");
    e.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 12);
    e.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial");
    e.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 285f);
    e.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 20f);

    final MasterReport report = new MasterReport();
    report.getReportHeader().addElement(e);

    final LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, report.getReportHeader(), false, false);
    logicalPageBox.getRepeatFooterArea().setY(logicalPageBox.getContentArea().getHeight());
    logicalPageBox.getFooterArea().setY(logicalPageBox.getContentArea().getHeight());

    // ModelPrinter.INSTANCE.print(logicalPageBox);

    final RenderNode[] elementsByNodeType =
        MatchFactory.findElementsByNodeType(logicalPageBox, LayoutNodeTypes.TYPE_NODE_TEXT);
    assertEquals(
        17, elementsByNodeType.length); // quick and easy way to see that all elements are there.

    // debugPrintText(elementsByNodeType);

    final LocalFontRegistry registry = new LocalFontRegistry();
    registry.initialize();

    final GraphicsOutputProcessorMetaData metaData =
        new GraphicsOutputProcessorMetaData(new DefaultFontStorage(registry));
    metaData.initialize(report.getConfiguration());

    final LogicalPageDrawable drawable = new LogicalPageDrawable();
    drawable.init(logicalPageBox, metaData, report.getResourceManager());

    final TracingGraphics g2 = new TracingGraphics();
    drawable.draw(g2, new Rectangle2D.Double(0, 0, 500, 500));
    /*
        for (int i = 0; i < g2.records.size(); i++)
        {
          final TextTraceRecord record = g2.records.get(i);
          System.out.println ("goldenSamples.add(new TextTraceRecord(" + record.x + ", " + record.y + ", \"" + record.text +"\"));");
        }
    */
    assertEquals(getSamples(), g2.records);
  }
  @Test
  public void testCsv() throws Exception {
    URL url = getClass().getResource("BACKLOG-7181.prpt");
    MasterReport report =
        (MasterReport) new ResourceManager().createDirectly(url, MasterReport.class).getResource();
    org.pentaho.reporting.engine.classic.core.testsupport.DebugReportRunner.createTestOutputFile();

    try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) {
      CSVReportUtil.createCSV(report, stream, null);
      final byte[] bytes = stream.toByteArray();
      Assert.assertNotNull(bytes);
      Assert.assertTrue(bytes.length > 0);
    }
  }
  @Test
  public void testPrd3857Report() throws Exception {
    File file = GoldenSampleGenerator.locateGoldenSampleReport("Prd-3857-001.prpt");
    Assert.assertNotNull(file);

    final ResourceManager manager = new ResourceManager();
    manager.registerDefaults();
    final Resource res = manager.createDirectly(file, MasterReport.class);
    final MasterReport report = (MasterReport) res.getResource();

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1);
    assertPageValid(pages, 0);
    assertPageValid(pages, 1);
  }
  @Test
  public void testRunSimpleReport() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    table.setName("table");
    report.getReportHeader().addElement(table);
    report.getReportHeader().setLayout("block");

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);
    assertPageValid(pages, 0);
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
  }
Пример #23
0
  public void testExcelExport() throws Exception {
    final MasterReport report = DebugReportRunner.parseGoldenSampleReport("Prd-3625.prpt");

    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ExcelReportUtil.createXLS(report, bout);

    final HSSFWorkbook wb = new HSSFWorkbook(new ByteArrayInputStream(bout.toByteArray()));
    final HSSFSheet sheetAt = wb.getSheetAt(0);
    final HSSFRow row = sheetAt.getRow(0);
    final HSSFCell cell0 = row.getCell(0);
    assertEquals(Cell.CELL_TYPE_NUMERIC, cell0.getCellType());
    assertEquals("yyyy-MM-dd", cell0.getCellStyle().getDataFormatString());
    final HSSFCell cell1 = row.getCell(1);
    assertEquals(Cell.CELL_TYPE_NUMERIC, cell1.getCellType());
    assertEquals("#,###.00;(#,###.00)", cell1.getCellStyle().getDataFormatString());
  }
  public void testWizardDefinitionIsAvailable() throws Exception {
    final File url = GoldTestBase.locateGoldenSampleReport("prd-2887.prpt");
    assertNotNull(url);
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    final Resource directly = resourceManager.createDirectly(url, MasterReport.class);
    final MasterReport org = (MasterReport) directly.getResource();

    assertNotNull(WizardProcessorUtil.loadWizardSpecification(org, resourceManager));
    final MasterReport report = postProcess(org);
    assertNotNull(WizardProcessorUtil.loadWizardSpecification(report, report.getResourceManager()));
    DetailsHeader detailsHeader = report.getDetailsHeader();
    detailsHeader.getElement(0).setName("MagicChange");

    LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 1);
    ModelPrinter.INSTANCE.print(logicalPageBox);
  }
  public void testValidate() throws ReportProcessingException, ContentProcessingException {
    final MasterReport report = new MasterReport();
    final DefaultProcessingContext processingContext = new DefaultProcessingContext(report);

    final LogicalPageBox pageBox = DebugReportRunner.layoutSingleBand(report, createTable());
    assertTrue(new ValidateModelStep().isLayoutable(pageBox));
    new TableValidationStep().validate(pageBox);
    new ParagraphLineBreakStep().compute(pageBox);

    final ComputeStaticPropertiesProcessStep computeStaticPropertiesProcessStep =
        new ComputeStaticPropertiesProcessStep();
    computeStaticPropertiesProcessStep.initialize(
        processingContext.getOutputProcessorMetaData(), processingContext);
    computeStaticPropertiesProcessStep.compute(pageBox);

    // ModelPrinter.print(pageBox);
  }
  @Test
  public void testBlockWithPrePostPad() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    table.setName("table");
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Pre-Padding", 100, 10));
    report.getReportHeader().addElement(table);
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Post-Padding", 100, 10));
    report.getReportHeader().setLayout("block");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-output-block.pdf");

    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);
    assertPageValid(pages, 0, StrictGeomUtility.toInternalValue(10));
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
    //    assertPageValid(report, 3);
    //    assertPageValid(report, 4);
  }
  public void testResourceLabelAfterSerialization() throws Exception {
    final File url = GoldTestBase.locateGoldenSampleReport("Prd-3514.prpt");
    assertNotNull(url);
    final ResourceManager resourceManager = new ResourceManager();
    resourceManager.registerDefaults();
    final Resource directly = resourceManager.createDirectly(url, MasterReport.class);
    final MasterReport org = (MasterReport) directly.getResource();

    final MasterReport report = postProcess(org);

    RelationalGroup relationalGroup = report.getRelationalGroup(0);
    GroupHeader header = relationalGroup.getHeader();
    Band band = (Band) header.getElement(0);
    Element element = band.getElement(1);
    assertTrue(element.getElementType() instanceof ResourceMessageType);
    element.setName("DateTitleField");
    //    LogicalPageBox logicalPageBox = DebugReportRunner.layoutPage(report, 1);
    LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, header, false, false);
    RenderNode dateTitleField = MatchFactory.findElementByName(logicalPageBox, "DateTitleField");
    assertNotNull(dateTitleField);
    //    ModelPrinter.INSTANCE.print(logicalPageBox);
  }
  @Test
  public void testRowWithPrePostPad() throws Exception {
    final MasterReport report = new MasterReport();
    report.setDataFactory(new TableDataFactory("query", new DefaultTableModel(10, 1)));
    report.setQuery("query");

    final Band table = TableTestUtil.createTable(1, 1, 6, true);
    table.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 200f);
    table.setName("table");
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Pre-Padding", 100, 10));
    report.getReportHeader().addElement(table);
    report.getReportHeader().addElement(TableTestUtil.createDataItem("Post-Padding", 100, 10));
    report.getReportHeader().setLayout("row");

    PdfReportUtil.createPDF(report, "test-output/PRD-3857-output-row.pdf");
    List<LogicalPageBox> pages = DebugReportRunner.layoutPages(report, 0, 1, 2);

    assertPageValid(pages, 0);
    assertPageValid(pages, 1);
    assertPageValid(pages, 2);
    //    assertPageValid(report, 3);
    //    assertPageValid(report, 4);
  }
  public void testWeirdTocLayout() throws ReportProcessingException, ContentProcessingException {
    Element textField = new Element();
    textField.setName("textField");
    textField.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial");
    textField.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 14);
    textField.getStyle().setStyleProperty(TextStyleKeys.TEXT_WRAP, TextWrap.NONE);
    textField.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 97f);
    textField.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 20f);
    textField.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 0f);
    textField.getStyle().setStyleProperty(ElementStyleKeys.POS_Y, 0f);
    textField.setElementType(LabelType.INSTANCE);
    textField.setAttribute(
        AttributeNames.Core.NAMESPACE, AttributeNames.Core.VALUE, "Classic Cars");

    Element dotField = new Element();
    dotField.setName("dotField");
    dotField.getStyle().setStyleProperty(TextStyleKeys.FONT, "Arial");
    dotField.getStyle().setStyleProperty(TextStyleKeys.FONTSIZE, 14);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.ALIGNMENT, ElementAlignment.RIGHT);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.VALIGNMENT, ElementAlignment.TOP);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.POS_X, 97f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.POS_Y, 0f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 628.463f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 20f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.WIDTH, 100f);
    dotField.getStyle().setStyleProperty(ElementStyleKeys.MAX_WIDTH, 100f);
    dotField.setElementType(LabelType.INSTANCE);
    dotField.setAttribute(
        AttributeNames.Core.NAMESPACE,
        AttributeNames.Core.VALUE,
        " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
            + " . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . "
            + ". . . . . . . . . . . . . . . . . .");

    Band band = new Band();
    band.setName("outer-box");
    band.setLayout("inline");
    band.getStyle().setStyleProperty(ElementStyleKeys.BOX_SIZING, BoxSizing.CONTENT_BOX);
    band.getStyle().setStyleProperty(ElementStyleKeys.OVERFLOW_X, false);
    band.getStyle().setStyleProperty(ElementStyleKeys.OVERFLOW_Y, false);
    band.getStyle().setStyleProperty(TextStyleKeys.LINEHEIGHT, 1f);
    band.getStyle()
        .setStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE, WhitespaceCollapse.PRESERVE_BREAKS);
    band.getStyle().setStyleProperty(ElementStyleKeys.MIN_WIDTH, 708f);
    band.getStyle().setStyleProperty(ElementStyleKeys.MIN_HEIGHT, 12f);
    band.getStyle().setStyleProperty(ElementStyleKeys.MAX_HEIGHT, 20f);
    band.addElement(textField);
    band.addElement(dotField);

    final MasterReport report = new MasterReport();
    report.getReportHeader().addElement(band);

    LogicalPageBox logicalPageBox =
        DebugReportRunner.layoutSingleBand(report, report.getReportHeader(), false, false);
    // ModelPrinter.INSTANCE.print(logicalPageBox);

    RenderBox outerBox = (RenderBox) MatchFactory.findElementByName(logicalPageBox, "outer-box");
    RenderNode dotFieldBox = MatchFactory.findElementByName(logicalPageBox, "dotField");
    RenderNode textFieldBox = MatchFactory.findElementByName(logicalPageBox, "textField");
    assertNotNull(outerBox);
    assertNotNull(dotFieldBox);
    assertNotNull(textFieldBox);

    assertEquals(0, outerBox.getY());
    assertEquals(0, dotFieldBox.getY());
    assertEquals(0, textFieldBox.getY());

    // box only contains one line, and min-size is set to 8, max size = 20, so the line-height of
    // 14.024 is used.
    assertEquals(StrictGeomUtility.toInternalValue(14.024), outerBox.getHeight());
    assertEquals(StrictGeomUtility.toInternalValue(14.024), outerBox.getFirstChild().getHeight());
    assertEquals(StrictGeomUtility.toInternalValue(14), dotFieldBox.getHeight());
    assertEquals(StrictGeomUtility.toInternalValue(14), textFieldBox.getHeight());
  }
Пример #30
0
 public void testOrphan1Crash() throws Exception {
   final MasterReport masterReport =
       DebugReportRunner.parseGoldenSampleReport("Prd-2087-Orphan-0.prpt");
   masterReport.setCompatibilityLevel(ClassicEngineBoot.computeVersionId(3, 8, 0));
   DebugReportRunner.createXmlTablePageable(masterReport);
 }