1 package org.apache.maven.report.projectinfo;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.net.URL;
23
24 import com.meterware.httpunit.GetMethodWebRequest;
25 import com.meterware.httpunit.TextBlock;
26 import com.meterware.httpunit.WebConversation;
27 import com.meterware.httpunit.WebRequest;
28 import com.meterware.httpunit.WebResponse;
29
30
31
32
33
34
35 public class ProjectIndexPageReportTest
36 extends AbstractProjectInfoTestCase
37 {
38
39
40
41 private static final WebConversation WEB_CONVERSATION = new WebConversation();
42
43
44
45
46
47
48 public void testReport()
49 throws Exception
50 {
51 generateReport( "index", "index-plugin-config.xml" );
52 assertTrue( "Test html generated", getGeneratedReport( "index.html" ).exists() );
53
54 URL reportURL = getGeneratedReport( "index.html" ).toURI().toURL();
55 assertNotNull( reportURL );
56
57
58 WebRequest request = new GetMethodWebRequest( reportURL.toString() );
59 WebResponse response = WEB_CONVERSATION.getResponse( request );
60
61
62 assertTrue( response.isHTML() );
63 assertTrue( response.getContentLength() > 0 );
64
65
66 assertEquals( getString( "report.index.title" ), response.getTitle() );
67
68
69 TextBlock[] textBlocks = response.getTextBlocks();
70 assertEquals( getString( "report.index.title" ) + " " + getTestMavenProject().getName(),
71 textBlocks[0].getText() );
72 assertEquals( getString( "report.index.nodescription" ), textBlocks[1].getText() );
73 }
74 }