This is an automated email from the ASF dual-hosted git repository. joerghoh pushed a commit to branch SLING-13392 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-i18n.git
commit 3f4fd80fd61fd7c8abc0ccdd78dbe91bb132a08a Author: Joerg Hoh <[email protected]> AuthorDate: Wed Oct 14 22:32:17 2026 +0200 SLING-13392 added test descriptions --- .../ConcurrentJcrResourceBundleLoadingTest.java | 24 ++++++++++++++++++++-- .../i18n/it/EagerResourceBundleProviderIT.java | 5 +++++ .../sling/i18n/it/ResourceBundleProviderIT.java | 9 +++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java b/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java index 34bd61d..42cc8db 100644 --- a/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java +++ b/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java @@ -62,8 +62,8 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; /** - * Test case to verify that each bundle is only loaded once, even - * if concurrent requests for the same bundle are made. + * Verifies bundle caching, concurrent loading, and refreshed fallback chains + * with both eager preloading and lazy invalidation. */ @RunWith(Parameterized.class) public class ConcurrentJcrResourceBundleLoadingTest { @@ -158,6 +158,10 @@ public class ConcurrentJcrResourceBundleLoadingTest { assertEquals(1, germanSet.size()); } + /** + * Reloading a child must preserve its unchanged parent, both in the cache + * and in the child's fallback reference. + */ @Test public void newBundleUsedAfterReload() throws Exception { ResourceBundle english = provider.getResourceBundle(Locale.ENGLISH); @@ -175,6 +179,12 @@ public class ConcurrentJcrResourceBundleLoadingTest { assertSame(german2, provider.getResourceBundle(Locale.GERMAN)); } + /** + * Changes an English fallback shared by the de -> en, de_DE -> de -> en, + * and fr -> en chains. Refreshed children must reference the current parents + * and return the new fallback while retaining locale-specific overrides. + * An explicitly unnamed reload must leave the named bundle chain untouched. + */ @Test public void reloadedFallbacksUseCurrentParents() { Resource englishDictionary = createDictionary("en", "en"); @@ -217,6 +227,11 @@ public class ConcurrentJcrResourceBundleLoadingTest { assertEquals("Named English", named.getString("named")); } + /** + * Refreshes the named en -> de -> de_DE dependency chain and verifies its + * updated fallback value and parent references. Explicitly refreshing that + * basename must not replace the cached unnamed bundles. + */ @Test public void namedFallbackRefreshDoesNotReplaceOtherBasenames() { Resource dictionary = createDictionary("named-en", "en", "named"); @@ -254,6 +269,11 @@ public class ConcurrentJcrResourceBundleLoadingTest { return dictionary; } + /** + * Replacing a parent must also replace its dependent child and attach the + * child to the new parent. New bundle identities alone would miss a stale + * parent reference left by child-first eager refresh. + */ @Test public void newBundleUsedAsParentAfterReload() throws Exception { ResourceBundle english = provider.getResourceBundle(Locale.ENGLISH); diff --git a/src/test/java/org/apache/sling/i18n/it/EagerResourceBundleProviderIT.java b/src/test/java/org/apache/sling/i18n/it/EagerResourceBundleProviderIT.java index df51deb..51adde9 100644 --- a/src/test/java/org/apache/sling/i18n/it/EagerResourceBundleProviderIT.java +++ b/src/test/java/org/apache/sling/i18n/it/EagerResourceBundleProviderIT.java @@ -24,6 +24,11 @@ import org.ops4j.pax.exam.OptionUtils; import static org.ops4j.pax.exam.cm.ConfigurationAdminOptions.newConfiguration; +/** + * Runs the inherited repository-backed tests with eager preloading enabled, + * complementing the default lazy-loading suite. In particular, targeted fallback + * updates must rebuild dependent bundles against their refreshed parents. + */ public class EagerResourceBundleProviderIT extends ResourceBundleProviderIT { @Override diff --git a/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java b/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java index d5ae71c..b6e7255 100644 --- a/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java +++ b/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java @@ -175,9 +175,16 @@ public class ResourceBundleProviderIT extends I18nTestSupport { assertMessage(MSG_KEY1, Locale.ENGLISH, BASENAME, "overwritten"); } + /** + * Verifies that repository observation propagates an English fallback update + * to German, German-country, and French bundles after they have been cached. + * The nt:unstructured entry is supported by message loading but avoids the + * sling:MessageEntry detection that promotes edits to full rediscovery. + * This exercises targeted refresh, where stale parent references would + * otherwise leave dependent locales returning the old English value. + */ @Test public void testFallbackChangesForUntypedMessages() throws RepositoryException { - // Message loading also supports entries without the sling:MessageEntry type. Node message = enRoot.addNode("fallback", "nt:unstructured"); message.setProperty("sling:key", MSG_KEY2); message.setProperty("sling:message", "old English fallback");
