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
29
30
31
32
33
34 public class IndexReportTest extends AbstractProjectInfoTestCase {
35
36
37
38 private static final WebConversation WEB_CONVERSATION = new WebConversation();
39
40
41
42
43
44
45 public void testReport() throws Exception {
46 generateReport(getGoal(), "index-plugin-config.xml");
47 assertTrue("Test html generated", getGeneratedReport("index.html").exists());
48
49 URL reportURL = getGeneratedReport("index.html").toURI().toURL();
50 assertNotNull(reportURL);
51
52
53 WebRequest request = new GetMethodWebRequest(reportURL.toString());
54 WebResponse response = WEB_CONVERSATION.getResponse(request);
55
56
57 assertTrue(response.isHTML());
58 assertTrue(response.getContentLength() > 0);
59
60
61
62 String expectedTitle = prepareTitle("index project info", getString("report.index.title"));
63 assertEquals(expectedTitle, response.getTitle());
64
65
66 TextBlock[] textBlocks = response.getTextBlocks();
67 assertEquals(
68 getString("report.index.title") + " " + getTestMavenProject().getName(), textBlocks[1].getText());
69 assertEquals(getString("report.index.nodescription"), textBlocks[2].getText());
70 }
71
72 @Override
73 protected String getGoal() {
74 return "index";
75 }
76 }