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