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 import com.meterware.httpunit.WebTable;
30
31
32
33
34
35
36 public class DependenciesReportTest
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 generateReport( "dependencies", "dependencies-plugin-config.xml" );
53 assertTrue( "Test html generated", getGeneratedReport( "dependencies.html" ).exists() );
54
55 URL reportURL = getGeneratedReport( "dependencies.html" ).toURI().toURL();
56 assertNotNull( reportURL );
57
58
59 WebRequest request = new GetMethodWebRequest( reportURL.toString() );
60 WebResponse response = WEB_CONVERSATION.getResponse( request );
61
62
63 assertTrue( response.isHTML() );
64 assertTrue( response.getContentLength() > 0 );
65
66
67 assertEquals( getString( "report.dependencies.title" ), response.getTitle() );
68
69
70 WebTable[] webTables = response.getTables();
71 assertEquals( webTables.length, 1 );
72
73 assertEquals( webTables[0].getColumnCount(), 5 );
74 assertEquals( webTables[0].getRowCount(), 1 + getTestMavenProject().getDependencies().size() );
75
76
77 TextBlock[] textBlocks = response.getTextBlocks();
78 assertEquals( getString( "report.dependencies.title" ), textBlocks[0].getText() );
79 assertEquals( "test", textBlocks[1].getText() );
80 assertEquals( getString( "report.dependencies.intro.test" ), textBlocks[2].getText() );
81 assertEquals( getString( "report.dependencies.transitive.title" ), textBlocks[3].getText() );
82 assertEquals( getString( "report.dependencies.transitive.nolist" ), textBlocks[4].getText() );
83 assertEquals( getString( "report.dependencies.graph.title" ), textBlocks[5].getText() );
84 assertEquals( getString( "report.dependencies.graph.tree.title" ), textBlocks[6].getText() );
85 assertEquals( getString( "report.dependencies.graph.tables.licenses" ), textBlocks[7].getText() );
86 }
87 }