1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.report.projectinfo;
20
21 import java.net.URL;
22
23 import com.meterware.httpunit.GetMethodWebRequest;
24 import com.meterware.httpunit.TextBlock;
25 import com.meterware.httpunit.WebConversation;
26 import com.meterware.httpunit.WebRequest;
27 import com.meterware.httpunit.WebResponse;
28 import com.meterware.httpunit.WebTable;
29
30
31
32
33
34
35 public class DependenciesReportTest extends AbstractProjectInfoTestCase {
36
37
38
39 private static final WebConversation WEB_CONVERSATION = new WebConversation();
40
41
42
43
44
45
46 public void testReport() throws Exception {
47 generateReport(getGoal(), "dependencies-plugin-config.xml");
48 assertTrue(
49 "Test html generated", getGeneratedReport("dependencies.html").exists());
50
51 URL reportURL = getGeneratedReport("dependencies.html").toURI().toURL();
52 assertNotNull(reportURL);
53
54
55 WebRequest request = new GetMethodWebRequest(reportURL.toString());
56 WebResponse response = WEB_CONVERSATION.getResponse(request);
57
58
59 assertTrue(response.isHTML());
60 assertTrue(response.getContentLength() > 0);
61
62
63 String expectedTitle = prepareTitle("dependencies project info", getString("report.dependencies.title"));
64 assertEquals(expectedTitle, response.getTitle());
65
66
67 WebTable[] webTables = response.getTables();
68
69 assertEquals(webTables.length, 3);
70
71 assertEquals(webTables[0].getColumnCount(), 5);
72 assertEquals(
73 webTables[0].getRowCount(),
74 1 + getTestMavenProject().getDependencies().size());
75
76
77 TextBlock[] textBlocks = response.getTextBlocks();
78 assertEquals(getString("report.dependencies.title"), textBlocks[1].getText());
79 assertEquals("test", textBlocks[2].getText());
80 assertEquals(getString("report.dependencies.intro.test"), textBlocks[3].getText());
81 assertEquals(getString("report.dependencies.transitive.title"), textBlocks[4].getText());
82 assertEquals(getString("report.dependencies.transitive.nolist"), textBlocks[5].getText());
83 assertEquals(getString("report.dependencies.graph.title"), textBlocks[6].getText());
84 assertEquals(getString("report.dependencies.graph.tree.title"), textBlocks[7].getText());
85 assertEquals(getString("report.dependencies.graph.tables.licenses"), textBlocks[8].getText());
86 }
87
88 @Override
89 protected String getGoal() {
90 return "dependencies";
91 }
92 }