This is an automated email from the ASF dual-hosted git repository.

slachiewicz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git

commit 40ecca8bbdccb0ac10b6ad3f9d3d01cb7c01fd06
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Thu Nov 5 02:39:59 2026 +0000

    Test the plain classifier fallback with the default locale property set
    
    The fallback test passed with the root default locale even without the fix. 
A second surefire execution now forks a JVM with 
maven.doxiaSitetools.defaultLocale=en, where the old lookup for the default 
locale's own classifier misses the plain site descriptor. SiteTool.toLocale 
documents how it differs from the locales parameter, and DefaultSiteTool logs 
the default locale at debug level.
---
 doxia-integration-tools/pom.xml                    | 24 ++++++++++++++++++++++
 .../apache/maven/doxia/tools/DefaultSiteTool.java  |  9 ++++++++
 .../org/apache/maven/doxia/tools/SiteTool.java     |  3 ++-
 .../org/apache/maven/doxia/tools/SiteToolTest.java | 15 ++++++++++++++
 4 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/doxia-integration-tools/pom.xml b/doxia-integration-tools/pom.xml
index ef73897..44dc960 100644
--- a/doxia-integration-tools/pom.xml
+++ b/doxia-integration-tools/pom.xml
@@ -167,6 +167,30 @@
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <executions>
+          <!-- the default locale is read once per JVM, so the tests that 
depend on the property need their own fork -->
+          <execution>
+            <id>default-locale-property</id>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <configuration>
+              
<test>SiteToolTest#siteDescriptorFromRepositoryFallsBackToPlainClassifier+defaultLocaleComesFromSystemProperty</test>
+              <systemPropertyVariables>
+                
<maven.doxiaSitetools.defaultLocale>en</maven.doxiaSitetools.defaultLocale>
+              </systemPropertyVariables>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
   <reporting>
     <plugins>
       <plugin>
diff --git 
a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
 
b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
index dd7d901..68c4a59 100644
--- 
a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
+++ 
b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
@@ -135,6 +135,15 @@ public class DefaultSiteTool implements SiteTool {
     @Inject
     protected SiteModelInheritanceAssembler assembler;
 
+    /** Creates the tool and logs the default locale it works with. */
+    public DefaultSiteTool() {
+        LOGGER.debug(
+                "Default locale: {} (system property {}={})",
+                SiteTool.DEFAULT_LOCALE.toString().isEmpty() ? "root" : 
SiteTool.DEFAULT_LOCALE,
+                SiteTool.DEFAULT_LOCALE_PROPERTY,
+                System.getProperty(SiteTool.DEFAULT_LOCALE_PROPERTY));
+    }
+
     // ----------------------------------------------------------------------
     // Public methods
     // ----------------------------------------------------------------------
diff --git 
a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
 
b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
index 61166c0..32699ad 100644
--- 
a/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
+++ 
b/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
@@ -60,7 +60,8 @@ public interface SiteTool {
      * Parses a locale such as {@code en}, {@code en_US} or {@code 
en_US_POSIX}, the reverse of
      * {@link Locale#toString()}, or a language tag such as {@code en-US}. 
Never throws: a code it cannot read gives
      * as much of the locale as it could read. The {@code locales} parameter 
of the Maven Site Plugin is parsed the
-     * same way.
+     * same way, except that it rejects a code with more than three parts 
separated by {@code _}, where this method
+     * folds the rest into the variant.
      *
      * @param code the locale code, may be {@code null}
      * @return the locale, or {@link Locale#ROOT} when {@code code} is {@code 
null} or blank
diff --git 
a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
 
b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
index f42640f..e180b4a 100644
--- 
a/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
+++ 
b/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
@@ -61,11 +61,13 @@ import org.junit.jupiter.api.Test;
 import static org.codehaus.plexus.testing.PlexusExtension.getTestFile;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNotSame;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
 
 /**
  * @author <a href="mailto:[email protected]";>Vincent Siveton</a>
@@ -379,6 +381,19 @@ class SiteToolTest {
         assertEquals("maven-site-1.0-site.xml", descriptor.getName());
     }
 
+    /**
+     * Checks that the second surefire execution of this module, which sets 
the system property, reached the tool.
+     * It is skipped in the default execution.
+     */
+    @Test
+    void defaultLocaleComesFromSystemProperty() {
+        String property = System.getProperty(SiteTool.DEFAULT_LOCALE_PROPERTY);
+        assumeTrue(property != null);
+
+        assertEquals(SiteTool.toLocale(property), SiteTool.DEFAULT_LOCALE);
+        assertNotEquals(Locale.ROOT, SiteTool.DEFAULT_LOCALE);
+    }
+
     @Test
     void toLocale() {
         assertEquals(Locale.ROOT, SiteTool.toLocale(null));

Reply via email to