@Test public void testWriteJndi() throws NamingException, IOException { final String contextPath = "comp/env/"; final Context context = createNiceMock(Context.class); final NamingEnumeration<Binding> enumeration = createNiceMock(NamingEnumeration.class); expect(context.listBindings("java:" + contextPath)).andReturn(enumeration).anyTimes(); expect(enumeration.hasMore()).andReturn(true).times(6); expect(enumeration.next()).andReturn(new Binding("test value", "test value")).once(); expect(enumeration.next()) .andReturn(new Binding("test context", createNiceMock(Context.class))).once(); expect(enumeration.next()).andReturn(new Binding("", "test")).once(); expect(enumeration.next()) .andReturn(new Binding("java:/test context", createNiceMock(Context.class))).once(); expect(enumeration.next()).andReturn(new Binding("test null classname", null, null)).once(); expect(enumeration.next()).andThrow(new NamingException("test")).once(); final ServletContext servletContext = createNiceMock(ServletContext.class); expect(servletContext.getServerInfo()).andReturn("Mock").anyTimes(); replay(servletContext); Parameters.initialize(servletContext); replay(context); replay(enumeration); final List<JndiBinding> bindings = JndiBinding.listBindings(context, contextPath); final ByteArrayOutputStream output = new ByteArrayOutputStream(); final PdfOtherReport pdfOtherReport = new PdfOtherReport(TEST_APP, output); pdfOtherReport.writeJndi(bindings, contextPath); assertNotEmptyAndClear(output); verify(context); verify(enumeration); verify(servletContext); final PdfOtherReport pdfOtherReport2 = new PdfOtherReport(TEST_APP, output); final List<JndiBinding> bindings2 = Collections.emptyList(); pdfOtherReport2.writeJndi(bindings2, ""); assertNotEmptyAndClear(output); }
public void writeJndi(List<JndiBinding> jndiBindings, String path) throws IOException { try { document.open(); if (path.isEmpty()) { addParagraph(getString("Arbre_JNDI"), "jndi.png"); } else { addParagraph(getFormattedString("Arbre_JNDI_pour_contexte", path), "jndi.png"); } new PdfJndiReport(jndiBindings, document).toPdf(); } catch (final DocumentException e) { throw createIOException(e); } document.close(); }
PdfOtherReport { public void writeJndi(List<JndiBinding> jndiBindings, String path) throws IOException { try { document.open(); if (path.isEmpty()) { addParagraph(getString("Arbre_JNDI"), "jndi.png"); } else { addParagraph(getFormattedString("Arbre_JNDI_pour_contexte", path), "jndi.png"); } new PdfJndiReport(jndiBindings, document).toPdf(); } catch (final DocumentException e) { throw createIOException(e); } document.close(); } }
PdfOtherReport { public void writeJndi(List<JndiBinding> jndiBindings, String path) throws IOException { try { document.open(); if (path.isEmpty()) { addParagraph(getString("Arbre_JNDI"), "jndi.png"); } else { addParagraph(getFormattedString("Arbre_JNDI_pour_contexte", path), "jndi.png"); } new PdfJndiReport(jndiBindings, document).toPdf(); } catch (final DocumentException e) { throw createIOException(e); } document.close(); } PdfOtherReport(String application, OutputStream output); }
PdfOtherReport { public void writeJndi(List<JndiBinding> jndiBindings, String path) throws IOException { try { document.open(); if (path.isEmpty()) { addParagraph(getString("Arbre_JNDI"), "jndi.png"); } else { addParagraph(getFormattedString("Arbre_JNDI_pour_contexte", path), "jndi.png"); } new PdfJndiReport(jndiBindings, document).toPdf(); } catch (final DocumentException e) { throw createIOException(e); } document.close(); } PdfOtherReport(String application, OutputStream output); void close(); void writeSessionInformations(List<SessionInformations> sessionsInformations); void writeHeapHistogram(HeapHistogram heapHistogram); void writeHotspots(List<SampledMethod> hotspots); void writeProcessInformations(List<ProcessInformations> processInformations); void writeProcessInformations(
			Map<String, List<ProcessInformations>> processInformationsByTitle); void writeDatabaseInformations(DatabaseInformations databaseInformations); void writeJndi(List<JndiBinding> jndiBindings, String path); void writeMBeans(List<MBeanNode> mbeans); void writeMBeans(Map<String, List<MBeanNode>> mbeansByTitle); void writeAllCurrentRequestsAsPart(
			Map<JavaInformations, List<CounterRequestContext>> currentRequests, Collector collector,
			List<Counter> counters, long timeOfSnapshot); void writeRequestAndGraphDetail(Collector collector, CollectorServer collectorServer,
			Range range, String requestId); void writeRuntimeDependencies(Counter counter, Range range); void writeCounterSummaryPerClass(Collector collector, Counter counter, String requestId,
			Range range); void writeThreads(List<JavaInformations> javaInformationsList); }
PdfOtherReport { public void writeJndi(List<JndiBinding> jndiBindings, String path) throws IOException { try { document.open(); if (path.isEmpty()) { addParagraph(getString("Arbre_JNDI"), "jndi.png"); } else { addParagraph(getFormattedString("Arbre_JNDI_pour_contexte", path), "jndi.png"); } new PdfJndiReport(jndiBindings, document).toPdf(); } catch (final DocumentException e) { throw createIOException(e); } document.close(); } PdfOtherReport(String application, OutputStream output); void close(); void writeSessionInformations(List<SessionInformations> sessionsInformations); void writeHeapHistogram(HeapHistogram heapHistogram); void writeHotspots(List<SampledMethod> hotspots); void writeProcessInformations(List<ProcessInformations> processInformations); void writeProcessInformations(
			Map<String, List<ProcessInformations>> processInformationsByTitle); void writeDatabaseInformations(DatabaseInformations databaseInformations); void writeJndi(List<JndiBinding> jndiBindings, String path); void writeMBeans(List<MBeanNode> mbeans); void writeMBeans(Map<String, List<MBeanNode>> mbeansByTitle); void writeAllCurrentRequestsAsPart(
			Map<JavaInformations, List<CounterRequestContext>> currentRequests, Collector collector,
			List<Counter> counters, long timeOfSnapshot); void writeRequestAndGraphDetail(Collector collector, CollectorServer collectorServer,
			Range range, String requestId); void writeRuntimeDependencies(Counter counter, Range range); void writeCounterSummaryPerClass(Collector collector, Counter counter, String requestId,
			Range range); void writeThreads(List<JavaInformations> javaInformationsList);  }