Skip to content

Commit c031699

Browse files
committed
[MPIR-435] Custom bundle sometimes not loaded due to parent-first class loading
This closes #48
1 parent 3cb4a73 commit c031699

File tree

9 files changed

+211
-7
lines changed

9 files changed

+211
-7
lines changed

src/it/full-pom/src/site/custom/project-info-reports.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
# to you under the Apache License, Version 2.0 (the
66
# "License"); you may not use this file except in compliance
77
# with the License. You may obtain a copy of the License at
8-
#
8+
#
99
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
10+
#
1111
# Unless required by applicable law or agreed to in writing,
1212
# software distributed under the License is distributed on an
1313
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
report.mailing-lists.intro = mail list intro text foo
18+
report.mailing-lists.intro = mail list intro text foo
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
report.mailing-lists.intro = mail list intro text foo ("de")
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
report.mailing-lists.intro = mail list intro text foo ("fr")

src/it/full-pom/verify.bsh

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,30 @@ try
9191
return false;
9292
}
9393

94+
mailinglists = new File( siteDir, "de/mailing-lists.html");
95+
content = FileUtils.fileRead( mailinglists, "UTF-8" );
96+
if ( !content.contains( "mail list intro text foo ("de")" ) )
97+
{
98+
System.err.println( "de/mailing-lists.html doesn't contain mail list intro text foo (\"de\")" );
99+
return false;
100+
}
101+
102+
mailinglists = new File( siteDir, "fr/mailing-lists.html");
103+
content = FileUtils.fileRead( mailinglists, "UTF-8" );
104+
if ( !content.contains( "mail list intro text foo ("fr")" ) )
105+
{
106+
System.err.println( "fr/mailing-lists.html doesn't contain mail list intro text foo (\"fr\")" );
107+
return false;
108+
}
109+
110+
mailinglists = new File( siteDir, "sv/mailing-lists.html");
111+
content = FileUtils.fileRead( mailinglists, "UTF-8" );
112+
if ( !content.contains( "mail list intro text foo" ) )
113+
{
114+
System.err.println( "sv/mailing-lists.html doesn't contain mail list intro text foo" );
115+
return false;
116+
}
117+
94118
File dependencies = new File( siteDir, "dependencies.html");
95119
content = FileUtils.fileRead( dependencies, "UTF-8" );
96120
if ( !content.contains( "doxia-core-1.2.jar" ) )
@@ -107,16 +131,16 @@ try
107131
System.err.println( "MPIR-216: dependency-management doesn't contain doxia-sink-api url https://maven.apache.org/doxia/doxia/doxia-sink-api/" );
108132
return false;
109133
}
110-
134+
111135
File dependencyConvergence = new File( siteDir, "dependency-convergence.html");
112136
content = FileUtils.fileRead( dependencyConvergence, "UTF-8" );
113-
137+
114138
if ( !content.contains( "You do not have 100% convergence." ) )
115139
{
116140
System.err.println( "dependency-convergence not rendered correctly" );
117141
return false;
118142
}
119-
143+
120144
}
121145
catch ( Throwable t )
122146
{

src/main/java/org/apache/maven/report/projectinfo/AbstractProjectInfoReport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ private static class CustomI18N implements I18N {
329329
URLClassLoader classLoader = null;
330330
try {
331331
classLoader = new URLClassLoader(
332-
new URL[] {customBundleFile.getParentFile().toURI().toURL()});
332+
new URL[] {customBundleFile.getParentFile().toURI().toURL()}, null);
333333
} catch (MalformedURLException e) {
334334
// could not happen.
335335
}

src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,33 @@ public void testReport() throws Exception {
8484
assertEquals("https://example.com/unsubscribe", unsubscribeLinks[0].getAttribute("href"));
8585
}
8686

87+
/**
88+
* Test custom bundle
89+
*
90+
* @throws Exception if any
91+
*/
92+
public void testCustomBundle() throws Exception {
93+
generateReport("mailing-lists", "custom-bundle/plugin-config.xml");
94+
assertTrue(
95+
"Test html generated", getGeneratedReport("mailing-lists.html").exists());
96+
97+
URL reportURL = getGeneratedReport("mailing-lists.html").toURI().toURL();
98+
assertNotNull(reportURL);
99+
100+
// HTTPUnit
101+
WebRequest request = new GetMethodWebRequest(reportURL.toString());
102+
WebResponse response = WEB_CONVERSATION.getResponse(request);
103+
104+
// Basic HTML tests
105+
assertTrue(response.isHTML());
106+
assertTrue(response.getContentLength() > 0);
107+
108+
// Test the texts
109+
TextBlock[] textBlocks = response.getTextBlocks();
110+
assertEquals(getString("report.mailing-lists.title"), textBlocks[0].getText());
111+
assertEquals("mail list intro text foo", textBlocks[1].getText());
112+
}
113+
87114
/**
88115
* Test report in French (MPIR-59)
89116
*
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.maven.report.projectinfo.stubs;
20+
21+
import java.io.File;
22+
23+
/**
24+
* @author <a href="mailto:[email protected]">Vincent Siveton</a>
25+
* @version $Id$
26+
*/
27+
public class MailingListsStub2 extends ProjectInfoProjectStub {
28+
@Override
29+
public File getBasedir() {
30+
return new File(super.getBasedir() + "/custom-bundle/");
31+
}
32+
33+
@Override
34+
protected String getPOM() {
35+
return "plugin-config.xml";
36+
}
37+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<!--
2+
Licensed to the Apache Software Foundation (ASF) under one
3+
or more contributor license agreements. See the NOTICE file
4+
distributed with this work for additional information
5+
regarding copyright ownership. The ASF licenses this file
6+
to you under the Apache License, Version 2.0 (the
7+
"License"); you may not use this file except in compliance
8+
with the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing,
13+
software distributed under the License is distributed on an
14+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
KIND, either express or implied. See the License for the
16+
specific language governing permissions and limitations
17+
under the License.
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<groupId>org.apache.maven.plugin.projectinfo.tests</groupId>
23+
<artifactId>mailing-lists</artifactId>
24+
<version>1.0-SNAPSHOT</version>
25+
<packaging>jar</packaging>
26+
<name>mailing lists project info</name>
27+
<url>http://maven.apache.org</url>
28+
<dependencies>
29+
<dependency>
30+
<groupId>junit</groupId>
31+
<artifactId>junit</artifactId>
32+
<version>3.8.1</version>
33+
<scope>test</scope>
34+
</dependency>
35+
</dependencies>
36+
<mailingLists>
37+
<mailingList>
38+
<name>Test List</name>
39+
<post>[email protected]</post>
40+
<subscribe>MAILTO:[email protected]</subscribe>
41+
</mailingList>
42+
<mailingList>
43+
<name>Test List 2</name>
44+
<post>[email protected]</post>
45+
<subscribe>MAILTO:[email protected]</subscribe>
46+
<unsubscribe>https://example.com/unsubscribe</unsubscribe>
47+
</mailingList>
48+
</mailingLists>
49+
<build>
50+
<plugins>
51+
<plugin>
52+
<artifactId>maven-project-info-reports-plugin</artifactId>
53+
<configuration>
54+
<outputDirectory>target/test-harness/mailing-lists</outputDirectory>
55+
<localRepository>${localRepository}</localRepository>
56+
<project implementation="org.apache.maven.report.projectinfo.stubs.MailingListsStub2"/>
57+
<customBundle>${basedir}/src/test/resources/plugin-configs/custom-bundle/src/site/custom/project-info-reports.properties</customBundle>
58+
</configuration>
59+
</plugin>
60+
</plugins>
61+
</build>
62+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
report.mailing-lists.intro = mail list intro text foo

0 commit comments

Comments
 (0)