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.io.File;
22 import java.net.URL;
23
24 import com.meterware.httpunit.GetMethodWebRequest;
25 import com.meterware.httpunit.TableCell;
26 import com.meterware.httpunit.TextBlock;
27 import com.meterware.httpunit.WebConversation;
28 import com.meterware.httpunit.WebLink;
29 import com.meterware.httpunit.WebRequest;
30 import com.meterware.httpunit.WebResponse;
31 import com.meterware.httpunit.WebTable;
32
33
34
35
36
37
38 public class TeamReportTest extends AbstractProjectInfoTestCase {
39
40
41
42 private static final WebConversation WEB_CONVERSATION = new WebConversation();
43
44
45
46
47
48
49 public void testReport() throws Exception {
50 File pluginXmlFile = new File(getBasedir(), "src/test/resources/plugin-configs/" + "team-plugin-config.xml");
51 AbstractProjectInfoReport mojo = createReportMojo(getGoal(), pluginXmlFile);
52 setVariableValueToObject(mojo, "showAvatarImages", Boolean.TRUE);
53 generateReport(mojo, pluginXmlFile);
54 assertTrue("Test html generated", getGeneratedReport("team.html").exists());
55
56 URL reportURL = getGeneratedReport("team.html").toURI().toURL();
57 assertNotNull(reportURL);
58
59
60 WebRequest request = new GetMethodWebRequest(reportURL.toString());
61 WebResponse response = WEB_CONVERSATION.getResponse(request);
62
63
64 assertTrue(response.isHTML());
65 assertTrue(response.getContentLength() > 0);
66
67
68 String expectedTitle = prepareTitle("team project info", getString("report.team.title"));
69 assertEquals(expectedTitle, response.getTitle());
70
71 assertTrue(response.getText().contains("gravatar"));
72
73
74 TextBlock[] textBlocks = response.getTextBlocks();
75
76 assertEquals(9, textBlocks.length - 1);
77 assertEquals(getString("report.team.intro.title"), textBlocks[1].getText());
78 assertEquals(getString("report.team.intro.description1"), textBlocks[2].getText());
79 assertEquals(getString("report.team.intro.description2"), textBlocks[3].getText());
80 assertEquals(getString("report.team.developers.title"), textBlocks[4].getText());
81 assertEquals(getString("report.team.developers.intro"), textBlocks[5].getText());
82 assertEquals(getString("report.team.contributors.title"), textBlocks[6].getText());
83 assertEquals(getString("report.team.nocontributor"), textBlocks[7].getText());
84
85 WebTable[] tables = response.getTables();
86 assertEquals(1, tables.length);
87 TableCell emailCell = tables[0].getTableCell(1, 3);
88 assertEquals("vsiveton@apache.org", emailCell.getText());
89 WebLink[] links = emailCell.getLinks();
90 assertEquals(1, links.length);
91 assertEquals("mailto:vsiveton@apache.org", links[0].getURLString());
92 }
93
94 @Override
95 protected String getGoal() {
96 return "team";
97 }
98 }