Skip to content

Commit 93bbe33

Browse files
authored
[JXR-153] use locales for string comparison (#28)
* [JXR-153] use locales for string comparison
1 parent 6df9ba3 commit 93bbe33

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrReport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,14 @@ protected List<String> getSourceRoots()
8888

8989
List<String> l = new ArrayList<>();
9090

91-
if ( !"pom".equals( getProject().getPackaging().toLowerCase() ) )
91+
if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) )
9292
{
9393
l.addAll( sourceDirs );
9494
}
9595

9696
if ( getProject().getExecutionProject() != null )
9797
{
98-
if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase() ) )
98+
if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
9999
{
100100
l.addAll( getProject().getExecutionProject().getCompileSourceRoots() );
101101
}
@@ -109,14 +109,14 @@ protected List<String> getSourceRoots( MavenProject project )
109109
{
110110
List<String> l = new ArrayList<>();
111111

112-
if ( !"pom".equals( project.getPackaging().toLowerCase() ) )
112+
if ( !"pom".equals( project.getPackaging().toLowerCase( Locale.US ) ) )
113113
{
114114
l.addAll( project.getCompileSourceRoots() );
115115
}
116116

117117
if ( project.getExecutionProject() != null )
118118
{
119-
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
119+
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
120120
{
121121
l.addAll( project.getExecutionProject().getCompileSourceRoots() );
122122
}

maven-jxr-plugin/src/main/java/org/apache/maven/plugin/jxr/JxrTestReport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ protected List<String> getSourceRoots()
6666
{
6767
List<String> l = new ArrayList<String>();
6868

69-
if ( !"pom".equals( getProject().getPackaging().toLowerCase() ) )
69+
if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) )
7070
{
7171
l.addAll( sourceDirs );
7272
}
7373

7474
if ( getProject().getExecutionProject() != null )
7575
{
76-
if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase() ) )
76+
if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
7777
{
7878
l.addAll( getProject().getExecutionProject().getTestCompileSourceRoots() );
7979
}
@@ -89,7 +89,7 @@ protected List<String> getSourceRoots( MavenProject project )
8989

9090
if ( project.getExecutionProject() != null )
9191
{
92-
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
92+
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
9393
{
9494
l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
9595
}

maven-jxr-plugin/src/test/java/org/apache/maven/plugin/jxr/JxrReportTest.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.io.File;
2727
import java.io.FileReader;
2828
import java.io.IOException;
29+
import java.util.Locale;
2930

3031
/**
3132
* @author <a href="mailto:[email protected]">Maria Odea Ching</a>
@@ -66,7 +67,7 @@ public void testDefaultConfiguration()
6667

6768
//check if there's a link to the javadoc files
6869
String str = readFile( new File( xrefDir, "def/configuration/AppSample.html" ) );
69-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/AppSample.html\"".toLowerCase() ) != -1 );
70+
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/appsample.html\"" ) != -1 );
7071

7172
str = readFile( new File( xrefDir, "def/configuration/App.html" ) );
7273
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/app.html\"".toLowerCase() ) != -1 );
@@ -107,10 +108,10 @@ public void testJdk4Configuration()
107108

108109
//check if there's a link to the javadoc files
109110
String str = readFile( new File( xrefDir, "def/configuration/AppSample.html" ) );
110-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/AppSample.html\"".toLowerCase() ) != -1 );
111+
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/appsample.html\"" ) != -1 );
111112

112113
str = readFile( new File( xrefDir, "def/configuration/App.html" ) );
113-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/app.html\"".toLowerCase() ) != -1 );
114+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/def/configuration/app.html\"" ) != -1 );
114115

115116
// check if encoding is UTF-8, the default value
116117
assertTrue( str.indexOf( "text/html; charset=UTF-8" ) != -1 );
@@ -148,10 +149,10 @@ public void testJdk6Configuration()
148149

149150
//check if there's a link to the javadoc files
150151
String str = readFile( new File( xrefDir, "def/configuration/AppSample.html" ) );
151-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/AppSample.html\"".toLowerCase() ) != -1 );
152+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/def/configuration/appsample.html\"" ) != -1 );
152153

153154
str = readFile( new File( xrefDir, "def/configuration/App.html" ) );
154-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/app.html\"".toLowerCase() ) != -1 );
155+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/def/configuration/app.html\"" ) != -1 );
155156

156157
// check if encoding is UTF-8, the default value
157158
assertTrue( str.indexOf( "text/html; charset=UTF-8" ) != -1 );
@@ -193,10 +194,10 @@ public void testJdk7Configuration()
193194

194195
//check if there's a link to the javadoc files
195196
String str = readFile( new File( xrefDir, "def/configuration/AppSample.html" ) );
196-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/AppSample.html\"".toLowerCase() ) != -1 );
197+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/def/configuration/appsample.html\"" ) != -1 );
197198

198199
str = readFile( new File( xrefDir, "def/configuration/App.html" ) );
199-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/app.html\"".toLowerCase() ) != -1 );
200+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/def/configuration/app.html\"" ) != -1 );
200201

201202
// check if encoding is UTF-8, the default value
202203
assertTrue( str.indexOf( "text/html; charset=UTF-8" ) != -1 );
@@ -234,7 +235,7 @@ public void testJdk8Configuration()
234235

235236
//check if there's a link to the javadoc files
236237
String str = readFile( new File( xrefDir, "def/configuration/AppSample.html" ) );
237-
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/AppSample.html\"".toLowerCase() ) != -1 );
238+
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/appsample.html\"" ) != -1 );
238239

239240
str = readFile( new File( xrefDir, "def/configuration/App.html" ) );
240241
assertTrue( str.toLowerCase().indexOf( "/apidocs/def/configuration/app.html\"".toLowerCase() ) != -1 );
@@ -275,15 +276,15 @@ public void testNoJavadocLink()
275276
//check if there's a link to the javadoc files
276277
String str = readFile( new File( xrefDir, "nojavadoclink/configuration/AppSample.html" ) );
277278
assertTrue(
278-
str.toLowerCase().indexOf( "/apidocs/nojavadoclink/configuration/AppSample.html\"".toLowerCase() ) == -1 );
279+
str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadoclink/configuration/appsample.html\"" ) == -1 );
279280

280281
str = readFile( new File( xrefDir, "nojavadoclink/configuration/App.html" ) );
281282
assertTrue(
282-
str.toLowerCase().indexOf( "/apidocs/nojavadoclink/configuration/app.html\"".toLowerCase() ) == -1 );
283+
str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadoclink/configuration/app.html\"" ) == -1 );
283284

284285
str = readFile( new File( xrefDir, "nojavadoclink/configuration/sample/Sample.html" ) );
285286
assertTrue( str.toLowerCase().indexOf(
286-
"/apidocs/nojavadoclink/configuration/sample/sample.html\"".toLowerCase() ) == -1 );
287+
"/apidocs/nojavadoclink/configuration/sample/sample.html\"" ) == -1 );
287288

288289
// check if encoding is ISO-8859-1, like specified in the plugin configuration
289290
assertTrue( str.indexOf( "text/html; charset=ISO-8859-1" ) != -1 );
@@ -335,10 +336,10 @@ public void testNoJavadocDir()
335336

336337
//check if there's a link to the javadoc files
337338
String str = readFile( new File( xrefDir, "nojavadocdir/test/AppSample.html" ) );
338-
assertTrue( str.toLowerCase().indexOf( "/apidocs/nojavadocdir/test/AppSample.html".toLowerCase() ) != -1 );
339+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadocdir/test/appsample.html") != -1 );
339340

340341
str = readFile( new File( xrefDir, "nojavadocdir/test/App.html" ) );
341-
assertTrue( str.toLowerCase().indexOf( "/apidocs/nojavadocdir/test/app.html".toLowerCase() ) != -1 );
342+
assertTrue( str.toLowerCase( Locale.US ).indexOf( "/apidocs/nojavadocdir/test/app.html" ) != -1 );
342343

343344
}
344345

0 commit comments

Comments
 (0)