PdfReport { public void toPdf() throws IOException { try { document.open(); pdfCoreReport.toPdf(); } catch (final DocumentException e) { throw createIOException(e); } document.close(); } PdfReport(Collector collector, boolean collectorServer,
			List<JavaInformations> javaInformationsList, Range range, OutputStream output);  PdfReport(Collector collector, boolean collectorServer,
			List<JavaInformations> javaInformationsList, Period period, OutputStream output); static String getFileName(String application); static boolean shouldUseEnglishInsteadOfUkrainian(); void toPdf(); void preInitGraphs(Map<String, byte[]> newSmallGraphs,
			Map<String, byte[]> newSmallOtherGraphs, Map<String, byte[]> newLargeGraphs); void setCounterRange(Range counterRange); void setCurrentRequests(List<CounterRequestContext> currentRequests); void close();  }
@Test public void testToPdf() throws Exception { final Counter sqlCounter = new Counter("sql", "db.png"); final Counter counter = new Counter("http", "db.png", sqlCounter); final Counter errorCounter = new Counter(Counter.ERROR_COUNTER_NAME, null); final Counter jobCounter = TestHtmlReport.getJobCounter(); final List<Counter> counters = Arrays.asList(counter, sqlCounter, errorCounter, jobCounter); counter.addRequest("test1", 0, 0, 0, false, 1000); counter.addRequest("test2", 1000, 500, 500, false, 1000); counter.addRequest("test3", 10000, 500, 500, true, 10000); final Collector collector = new Collector("test", counters); final JavaInformations javaInformations = new JavaInformations(null, true); final List<JavaInformations> javaInformationsList = Collections .singletonList(javaInformations); counter.addRequest("test1", 0, 0, 0, false, 1000); collector.collectWithoutErrors(javaInformationsList); counter.clear(); collector.collectWithoutErrors(javaInformationsList); toPdf(collector, true, javaInformationsList, null); final JRobin jrobin = collector.getCounterJRobins().iterator().next(); final byte[] graph = jrobin.graph(Period.JOUR.getRange(), 50, 50); final Map<String, byte[]> graphs = new HashMap<String, byte[]>(); graphs.put("1", graph); graphs.put("2", graph); graphs.put("3", graph); graphs.put("4", graph); toPdf(collector, true, javaInformationsList, graphs); final Map<String, byte[]> emptyGraphs = Collections.emptyMap(); counter.bindContext("test 1", "complete test 1", null, -1, -1); sqlCounter.bindContext("sql1", "sql 1", null, -1, -1); sqlCounter.addRequest("sql1", 100, 100, 100, false, -1); counter.addRequest("test 1", 0, 0, 0, false, 1000); counter.addRequest("test2", 1000, 500, 500, false, 1000); counter.addRequest(buildLongRequestName(), 10000, 5000, 5000, true, 10000); collector.collectWithoutErrors(javaInformationsList); toPdf(collector, true, javaInformationsList, emptyGraphs); toPdf(collector, false, javaInformationsList, emptyGraphs); errorCounter.addRequestForSystemError("error", -1, -1, -1, null); errorCounter.addRequestForSystemError("error2", -1, -1, -1, "ma stack-trace"); toPdf(collector, false, javaInformationsList, emptyGraphs); rootContexts(counter, collector, javaInformations); cache(collector); job(collector); Utils.setProperty(Parameter.NO_DATABASE, Boolean.TRUE.toString()); toPdf(collector, false, javaInformationsList, emptyGraphs); Utils.setProperty(Parameter.NO_DATABASE, Boolean.FALSE.toString()); I18N.bindLocale(Locale.CHINA); try { toPdf(collector, false, javaInformationsList, emptyGraphs); } finally { I18N.unbindLocale(); } }
@Test public void testEmptyPdfCounterRequestContext() throws IOException, DocumentException { final ByteArrayOutputStream output = new ByteArrayOutputStream(); final PdfDocumentFactory pdfDocumentFactory = new PdfDocumentFactory(TEST_APP, null, output); final Document document = pdfDocumentFactory.createDocument(); document.open(); final PdfCounterRequestContextReport report = new PdfCounterRequestContextReport( Collections.<CounterRequestContext> emptyList(), Collections.<PdfCounterReport> emptyList(), Collections.<ThreadInformations> emptyList(), true, pdfDocumentFactory, document); report.toPdf(); report.setTimeOfSnapshot(System.currentTimeMillis()); report.writeContextDetails(); assertNotNull("PdfCounterRequestContextReport", report); }