Skip to content

Commit

Permalink
Specify locale for case conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo committed Dec 4, 2024
1 parent 31b9fa0 commit 1799d1a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1787,7 +1787,7 @@ protected File getClassesFile(MavenProject project) {
* @return the list of source paths for the given project
*/
protected List<String> getProjectSourceRoots(MavenProject p) {
if ("pom".equals(p.getPackaging().toLowerCase())) {
if ("pom".equals(p.getPackaging().toLowerCase(Locale.ENGLISH))) {
return Collections.emptyList();
}

Expand All @@ -1801,7 +1801,7 @@ protected List<String> getProjectSourceRoots(MavenProject p) {
* @return the list of source paths for the execution project of the given project
*/
protected List<String> getExecutionProjectSourceRoots(MavenProject p) {
if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase())) {
if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
Expand Down Expand Up @@ -189,7 +190,7 @@ protected List<File> getProjectBuildOutputDirs(MavenProject p) {

@Override
protected List<String> getProjectSourceRoots(MavenProject p) {
if ("pom".equals(p.getPackaging().toLowerCase())) {
if ("pom".equals(p.getPackaging().toLowerCase(Locale.ENGLISH))) {
return Collections.emptyList();
}

Expand All @@ -198,7 +199,7 @@ protected List<String> getProjectSourceRoots(MavenProject p) {

@Override
protected List<String> getExecutionProjectSourceRoots(MavenProject p) {
if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase())) {
if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ protected List<String> getProjectSourceRoots(MavenProject p) {

@Override
protected List<String> getExecutionProjectSourceRoots(MavenProject p) {
if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase())) {
if ("pom".equals(p.getExecutionProject().getPackaging().toLowerCase(Locale.ENGLISH))) {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -427,31 +428,31 @@ public void testCustomConfiguration() throws Exception {
// read the contents of the html files based on some of the parameter values
// author == false
String str = readFile(apidocs.resolve("custom/configuration/AppSample.html"));
assertFalse(str.toLowerCase().contains("author"));
assertFalse(str.toLowerCase(Locale.ENGLISH).contains("author"));

// bottom
assertTrue(str.toUpperCase().contains("SAMPLE BOTTOM CONTENT"));
assertTrue(str.toUpperCase(Locale.ENGLISH).contains("SAMPLE BOTTOM CONTENT"));

// offlineLinks
if (JavaVersion.JAVA_VERSION.isBefore("11.0.2")) {
assertThat(str)
.containsIgnoringCase("href=\"http://java.sun.com/j2se/1.4.2/docs/api/java/lang/string.html");
} else {
assertTrue(str.toLowerCase()
assertTrue(str.toLowerCase(Locale.ENGLISH)
.contains("href=\"http://java.sun.com/j2se/1.4.2/docs/api/java.base/java/lang/string.html"));
}

// header
assertTrue(str.toUpperCase().contains("MAVEN JAVADOC PLUGIN TEST"));
assertTrue(str.toUpperCase(Locale.ENGLISH).contains("MAVEN JAVADOC PLUGIN TEST"));

// footer
if (JavaVersion.JAVA_VERSION.isBefore("16-ea")
&& !System.getProperty("java.vm.name").contains("OpenJ9")) {
assertTrue(str.toUpperCase().contains("MAVEN JAVADOC PLUGIN TEST FOOTER"));
assertTrue(str.toUpperCase(Locale.ENGLISH).contains("MAVEN JAVADOC PLUGIN TEST FOOTER"));
}

// nohelp == true
assertFalse(str.toUpperCase().contains("/HELP-DOC.HTML"));
assertFalse(str.toUpperCase(Locale.ENGLISH).contains("/HELP-DOC.HTML"));

// check the wildcard (*) package exclusions -- excludePackageNames parameter
assertThat(apidocs.resolve("custom/configuration/exclude1/Exclude1App.html"))
Expand Down Expand Up @@ -798,8 +799,9 @@ public void testTag() throws Exception {
// which is not enough for Java 11 anymore
if (JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore("11")) {
assertThat(readed).contains(">Version:</");
assertTrue(readed.toLowerCase().contains("</dt>" + LINE_SEPARATOR + " <dd>1.0</dd>")
|| readed.toLowerCase().contains("</dt>" + LINE_SEPARATOR + "<dd>1.0</dd>" /* JDK 8 */));
assertTrue(readed.toLowerCase(Locale.ENGLISH).contains("</dt>" + LINE_SEPARATOR + " <dd>1.0</dd>")
|| readed.toLowerCase(Locale.ENGLISH)
.contains("</dt>" + LINE_SEPARATOR + "<dd>1.0</dd>" /* JDK 8 */));
}
}

Expand Down

0 comments on commit 1799d1a

Please sign in to comment.