Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MPIR-435] Custom bundle sometimes not loaded due to parent-first cla… #48

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

report.mailing-lists.intro = mail list intro text foo
report.mailing-lists.intro = mail list intro text foo
18 changes: 18 additions & 0 deletions src/it/full-pom/src/site/custom/project-info-reports_de.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

report.mailing-lists.intro = mail list intro text foo ("de")
18 changes: 18 additions & 0 deletions src/it/full-pom/src/site/custom/project-info-reports_fr.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

report.mailing-lists.intro = mail list intro text foo ("fr")
30 changes: 27 additions & 3 deletions src/it/full-pom/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,30 @@ try
return false;
}

mailinglists = new File( siteDir, "de/mailing-lists.html");
content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo ("de")" ) )
{
System.err.println( "de/mailing-lists.html doesn't contain mail list intro text foo (\"de\")" );
return false;
}

mailinglists = new File( siteDir, "fr/mailing-lists.html");
content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo ("fr")" ) )
{
System.err.println( "fr/mailing-lists.html doesn't contain mail list intro text foo (\"fr\")" );
return false;
}

mailinglists = new File( siteDir, "sv/mailing-lists.html");
content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo" ) )
{
System.err.println( "sv/mailing-lists.html doesn't contain mail list intro text foo" );
return false;
}

File dependencies = new File( siteDir, "dependencies.html");
content = FileUtils.fileRead( dependencies, "UTF-8" );
if ( !content.contains( "doxia-core-1.2.jar" ) )
Expand All @@ -107,16 +131,16 @@ try
System.err.println( "MPIR-216: dependency-management doesn't contain doxia-sink-api url https://maven.apache.org/doxia/doxia/doxia-sink-api/" );
return false;
}

File dependencyConvergence = new File( siteDir, "dependency-convergence.html");
content = FileUtils.fileRead( dependencyConvergence, "UTF-8" );

if ( !content.contains( "You do not have 100% convergence." ) )
{
System.err.println( "dependency-convergence not rendered correctly" );
return false;
}

}
catch ( Throwable t )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ private static class CustomI18N implements I18N {
URLClassLoader classLoader = null;
try {
classLoader = new URLClassLoader(
new URL[] {customBundleFile.getParentFile().toURI().toURL()});
new URL[] {customBundleFile.getParentFile().toURI().toURL()}, null);
} catch (MalformedURLException e) {
// could not happen.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,33 @@ public void testReport() throws Exception {
assertEquals("https://example.com/unsubscribe", unsubscribeLinks[0].getAttribute("href"));
}

/**
* Test custom bundle
*
* @throws Exception if any
*/
public void testCustomBundle() throws Exception {
generateReport("mailing-lists", "custom-bundle/plugin-config.xml");
assertTrue(
"Test html generated", getGeneratedReport("mailing-lists.html").exists());

URL reportURL = getGeneratedReport("mailing-lists.html").toURI().toURL();
assertNotNull(reportURL);

// HTTPUnit
WebRequest request = new GetMethodWebRequest(reportURL.toString());
WebResponse response = WEB_CONVERSATION.getResponse(request);

// Basic HTML tests
assertTrue(response.isHTML());
assertTrue(response.getContentLength() > 0);

// Test the texts
TextBlock[] textBlocks = response.getTextBlocks();
assertEquals(getString("report.mailing-lists.title"), textBlocks[0].getText());
assertEquals("mail list intro text foo", textBlocks[1].getText());
}

/**
* Test report in French (MPIR-59)
*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.report.projectinfo.stubs;

import java.io.File;

/**
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
*/
public class MailingListsStub2 extends ProjectInfoProjectStub {
@Override
public File getBasedir() {
return new File(super.getBasedir() + "/custom-bundle/");
}

@Override
protected String getPOM() {
return "plugin-config.xml";
}
}
62 changes: 62 additions & 0 deletions src/test/resources/plugin-configs/custom-bundle/plugin-config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.plugin.projectinfo.tests</groupId>
<artifactId>mailing-lists</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>mailing lists project info</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<mailingLists>
<mailingList>
<name>Test List</name>
<post>test@maven.apache.org</post>
<subscribe>MAILTO:test-subscribe@maven.apache.org</subscribe>
</mailingList>
<mailingList>
<name>Test List 2</name>
<post>test2@maven.apache.org</post>
<subscribe>MAILTO:test-subscribe2@maven.apache.org</subscribe>
<unsubscribe>https://example.com/unsubscribe</unsubscribe>
</mailingList>
</mailingLists>
<build>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<configuration>
<outputDirectory>target/test-harness/mailing-lists</outputDirectory>
<localRepository>${localRepository}</localRepository>
<project implementation="org.apache.maven.report.projectinfo.stubs.MailingListsStub2"/>
<customBundle>${basedir}/src/test/resources/plugin-configs/custom-bundle/src/site/custom/project-info-reports.properties</customBundle>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

report.mailing-lists.intro = mail list intro text foo