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 import java.util.Locale;
24
25 import org.apache.maven.report.projectinfo.MailingListsReport.MailingListsRenderer;
26
27 import junitx.util.PrivateAccessor;
28
29 import com.meterware.httpunit.GetMethodWebRequest;
30 import com.meterware.httpunit.TextBlock;
31 import com.meterware.httpunit.WebConversation;
32 import com.meterware.httpunit.WebRequest;
33 import com.meterware.httpunit.WebResponse;
34
35
36
37
38
39
40 public class MailingListsReportTest
41 extends AbstractProjectInfoTestCase
42 {
43
44
45
46 private static final WebConversation WEB_CONVERSATION = new WebConversation();
47
48
49
50
51
52
53 public void testReport()
54 throws Exception
55 {
56 generateReport( "mailing-lists", "mailing-lists-plugin-config.xml" );
57 assertTrue( "Test html generated", getGeneratedReport( "mailing-lists.html" ).exists() );
58
59 URL reportURL = getGeneratedReport( "mailing-lists.html" ).toURI().toURL();
60 assertNotNull( reportURL );
61
62
63 WebRequest request = new GetMethodWebRequest( reportURL.toString() );
64 WebResponse response = WEB_CONVERSATION.getResponse( request );
65
66
67 assertTrue( response.isHTML() );
68 assertTrue( response.getContentLength() > 0 );
69
70
71 String expectedTitle = prepareTitle( getString( "report.mailing-lists.name" ),
72 getString( "report.mailing-lists.title" ) );
73 assertEquals( expectedTitle, response.getTitle() );
74
75
76 TextBlock[] textBlocks = response.getTextBlocks();
77 assertEquals( getString( "report.mailing-lists.title" ), textBlocks[0].getText() );
78 assertEquals( getString( "report.mailing-lists.intro" ), textBlocks[1].getText() );
79 }
80
81
82
83
84
85
86 public void testFrenchReport()
87 throws Exception
88 {
89 Locale oldLocale = Locale.getDefault();
90
91 try
92 {
93 Locale.setDefault( Locale.FRENCH );
94
95 generateReport( "mailing-lists", "mailing-lists-plugin-config.xml" );
96 assertTrue( "Test html generated", getGeneratedReport( "mailing-lists.html" ).exists() );
97 }
98 finally
99 {
100 Locale.setDefault( oldLocale );
101 }
102 }
103
104
105
106
107 public void testGetArchiveServer()
108 throws Throwable
109 {
110 String server = "http://mail-archives.apache.org/mod_mbox/maven-announce/";
111 assertEquals( "mail-archives.apache.org", invokeGetArchiveServer( server ) );
112
113 server = "http://mail-archives.apache.org/mod_mbox/maven-announce";
114 assertEquals( "mail-archives.apache.org", invokeGetArchiveServer( server ) );
115
116 server = "http://www.mail-archive.com/announce@maven.apache.org";
117 assertEquals( "www.mail-archive.com", invokeGetArchiveServer( server ) );
118
119 server = "http://www.nabble.com/Maven-Announcements-f15617.html";
120 assertEquals( "www.nabble.com", invokeGetArchiveServer( server ) );
121
122 server = "http://maven.announce.markmail.org/";
123 assertEquals( "maven.announce.markmail.org", invokeGetArchiveServer( server ) );
124
125 server = "http://maven.announce.markmail.org";
126 assertEquals( "maven.announce.markmail.org", invokeGetArchiveServer( server ) );
127 }
128
129
130
131
132 private static String invokeGetArchiveServer( String s )
133 throws Throwable
134 {
135 return (String) PrivateAccessor.invoke( MailingListsRenderer.class, "getArchiveServer",
136 new Class[] { String.class }, new Object[] { s } );
137 }
138 }