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 public class ModulesReportTest
35 extends AbstractProjectInfoTestCase
36 {
37
38
39
40 private static final WebConversation WEB_CONVERSATION = new WebConversation();
41
42
43
44
45
46
47 public void testReport()
48 throws Exception
49 {
50 generateReport( "modules", "modules-plugin-config.xml" );
51 assertTrue( "Test html generated", getGeneratedReport( "modules.html" ).exists() );
52
53 URL reportURL = getGeneratedReport( "modules.html" ).toURI().toURL();
54 assertNotNull( reportURL );
55
56
57 WebRequest request = new GetMethodWebRequest( reportURL.toString() );
58 WebResponse response = WEB_CONVERSATION.getResponse( request );
59
60
61 assertTrue( response.isHTML() );
62 assertTrue( response.getContentLength() > 0 );
63
64
65 assertEquals( getString( "report.modules.title" ), response.getTitle() );
66
67
68 TextBlock[] textBlocks = response.getTextBlocks();
69 assertEquals( 2, textBlocks.length );
70 assertEquals( getString( "report.modules.title" ), textBlocks[0].getText() );
71 assertEquals( getString( "report.modules.intro" ), textBlocks[1].getText() );
72
73 String[][] cellTexts = response.getTables()[0].asText();
74 assertEquals( 3, cellTexts.length );
75 assertEquals( 2, cellTexts[0].length );
76 assertEquals( getString( "report.modules.header.name" ), cellTexts[0][0] );
77 assertEquals( getString( "report.modules.header.description" ), cellTexts[0][1] );
78 assertEquals( "project1", cellTexts[1][0] );
79 assertEquals( "-", cellTexts[1][1] );
80 assertEquals( "project2", cellTexts[2][0] );
81 assertEquals( "project2 description", cellTexts[2][1] );
82 }
83 }