@Test public void testDependencies() throws IOException { final ServletContext context = createNiceMock(ServletContext.class); final String javamelodyDir = "/META-INF/maven/net.bull.javamelody/"; final String webapp = javamelodyDir + "javamelody-test-webapp/"; expect(context.getResourcePaths("/META-INF/maven/")) .andReturn(Collections.singleton(javamelodyDir)).anyTimes(); expect(context.getResourcePaths(javamelodyDir)).andReturn(Collections.singleton(webapp)) .anyTimes(); final IAnswer<InputStream> answer = new IAnswer<InputStream>() { @Override public InputStream answer() throws Throwable { return getClass().getResourceAsStream("/pom.xml"); } }; expect(context.getResourceAsStream(webapp + "pom.xml")).andAnswer(answer).anyTimes(); final Set<String> dependencies = new LinkedHashSet<String>( Arrays.asList("/WEB-INF/lib/jrobin-1.5.9.jar", "/WEB-INF/lib/javamelody-core-1.65.0.jar", "/WEB-INF/lib/nothing.jar")); expect(context.getResourcePaths("/WEB-INF/lib/")).andReturn(dependencies).anyTimes(); expect(context.getMajorVersion()).andReturn(2).anyTimes(); expect(context.getMinorVersion()).andReturn(5).anyTimes(); replay(context); Parameters.initialize(context); final Map<String, MavenArtifact> webappDependencies = MavenArtifact.getWebappDependencies(); assertFalse("getWebappDependencies", webappDependencies.isEmpty()); verify(context); final StringWriter writer = new StringWriter(); final HtmlDependenciesReport htmlDependenciesReport = new HtmlDependenciesReport( webappDependencies, writer); htmlDependenciesReport.toHtml(); assertNotEmptyAndClear(writer); }
@Override void toHtml() throws IOException { writeBackLink(); writeln("<br/>"); if (dependencies.isEmpty()) { writeln("#Aucune_dependance#"); return; } writeTitle("beans.png", getString("Dependencies")); final HtmlTable table = new HtmlTable(); table.beginTable(getString("Dependencies")); write("<th>Artifact</th><th>#Nom#</th><th>Maven ID</th><th>#Licence#</th>"); for (final Map.Entry<String, MavenArtifact> entry : dependencies.entrySet()) { final String jarFilename = entry.getKey(); final MavenArtifact dependency = entry.getValue(); table.nextRow(); writeDependency(jarFilename, dependency); } table.endTable(); writeln("<div align='right'>" + getFormattedString("nb_dependencies", dependencies.size()) + "</div>"); }
HtmlDependenciesReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { writeBackLink(); writeln("<br/>"); if (dependencies.isEmpty()) { writeln("#Aucune_dependance#"); return; } writeTitle("beans.png", getString("Dependencies")); final HtmlTable table = new HtmlTable(); table.beginTable(getString("Dependencies")); write("<th>Artifact</th><th>#Nom#</th><th>Maven ID</th><th>#Licence#</th>"); for (final Map.Entry<String, MavenArtifact> entry : dependencies.entrySet()) { final String jarFilename = entry.getKey(); final MavenArtifact dependency = entry.getValue(); table.nextRow(); writeDependency(jarFilename, dependency); } table.endTable(); writeln("<div align='right'>" + getFormattedString("nb_dependencies", dependencies.size()) + "</div>"); } }
HtmlDependenciesReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { writeBackLink(); writeln("<br/>"); if (dependencies.isEmpty()) { writeln("#Aucune_dependance#"); return; } writeTitle("beans.png", getString("Dependencies")); final HtmlTable table = new HtmlTable(); table.beginTable(getString("Dependencies")); write("<th>Artifact</th><th>#Nom#</th><th>Maven ID</th><th>#Licence#</th>"); for (final Map.Entry<String, MavenArtifact> entry : dependencies.entrySet()) { final String jarFilename = entry.getKey(); final MavenArtifact dependency = entry.getValue(); table.nextRow(); writeDependency(jarFilename, dependency); } table.endTable(); writeln("<div align='right'>" + getFormattedString("nb_dependencies", dependencies.size()) + "</div>"); } HtmlDependenciesReport(Map<String, MavenArtifact> dependencies, Writer writer); }
HtmlDependenciesReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { writeBackLink(); writeln("<br/>"); if (dependencies.isEmpty()) { writeln("#Aucune_dependance#"); return; } writeTitle("beans.png", getString("Dependencies")); final HtmlTable table = new HtmlTable(); table.beginTable(getString("Dependencies")); write("<th>Artifact</th><th>#Nom#</th><th>Maven ID</th><th>#Licence#</th>"); for (final Map.Entry<String, MavenArtifact> entry : dependencies.entrySet()) { final String jarFilename = entry.getKey(); final MavenArtifact dependency = entry.getValue(); table.nextRow(); writeDependency(jarFilename, dependency); } table.endTable(); writeln("<div align='right'>" + getFormattedString("nb_dependencies", dependencies.size()) + "</div>"); } HtmlDependenciesReport(Map<String, MavenArtifact> dependencies, Writer writer);  }
HtmlDependenciesReport extends HtmlAbstractReport { @Override void toHtml() throws IOException { writeBackLink(); writeln("<br/>"); if (dependencies.isEmpty()) { writeln("#Aucune_dependance#"); return; } writeTitle("beans.png", getString("Dependencies")); final HtmlTable table = new HtmlTable(); table.beginTable(getString("Dependencies")); write("<th>Artifact</th><th>#Nom#</th><th>Maven ID</th><th>#Licence#</th>"); for (final Map.Entry<String, MavenArtifact> entry : dependencies.entrySet()) { final String jarFilename = entry.getKey(); final MavenArtifact dependency = entry.getValue(); table.nextRow(); writeDependency(jarFilename, dependency); } table.endTable(); writeln("<div align='right'>" + getFormattedString("nb_dependencies", dependencies.size()) + "</div>"); } HtmlDependenciesReport(Map<String, MavenArtifact> dependencies, Writer writer);   }