Skip to content

Commit

Permalink
[JXR-153] use locales for string comparison (#28)
Browse files Browse the repository at this point in the history
* [JXR-153] use locales for string comparison
  • Loading branch information
elharo committed Feb 6, 2021
1 parent 6df9ba3 commit 93bbe33
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@ protected List<String> getSourceRoots()

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

if ( !"pom".equals( getProject().getPackaging().toLowerCase() ) )
if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) )
{
l.addAll( sourceDirs );
}

if ( getProject().getExecutionProject() != null )
{
if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase() ) )
if ( !"pom".equals( getProject().getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
{
l.addAll( getProject().getExecutionProject().getCompileSourceRoots() );
}
Expand All @@ -109,14 +109,14 @@ protected List<String> getSourceRoots( MavenProject project )
{
List<String> l = new ArrayList<>();

if ( !"pom".equals( project.getPackaging().toLowerCase() ) )
if ( !"pom".equals( project.getPackaging().toLowerCase( Locale.US ) ) )
{
l.addAll( project.getCompileSourceRoots() );
}

if ( project.getExecutionProject() != null )
{
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
{
l.addAll( project.getExecutionProject().getCompileSourceRoots() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ protected List<String> getSourceRoots()
{
List<String> l = new ArrayList<String>();

if ( !"pom".equals( getProject().getPackaging().toLowerCase() ) )
if ( !"pom".equals( getProject().getPackaging().toLowerCase( Locale.US ) ) )
{
l.addAll( sourceDirs );
}

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

if ( project.getExecutionProject() != null )
{
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase() ) )
if ( !"pom".equals( project.getExecutionProject().getPackaging().toLowerCase( Locale.US ) ) )
{
l.addAll( project.getExecutionProject().getTestCompileSourceRoots() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Locale;

/**
* @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
Expand Down Expand Up @@ -66,7 +67,7 @@ public void testDefaultConfiguration()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

}

Expand Down

0 comments on commit 93bbe33

Please sign in to comment.