From 9fa7bbce96140bda8218ff987ba3e9e121bec870 Mon Sep 17 00:00:00 2001 From: abirembaut Date: Wed, 18 Oct 2023 10:40:07 +0200 Subject: [PATCH] fix(i18n): subscription translations not loaded * fix PathPatternMatching to load resources from all jars * adapt tests that were already showing the issue (only resources from src/test/resources/i18n were loaded. src/main/resources/i18n was ignored) Covers [RUNTIME-1769](https://bonitasoft.atlassian.net/browse/RUNTIME-1769) Report of https://github.com/bonitasoft/bonita-web-sp/commit/6f8f9ed60ff73867bbaaa535caa989594c96b254 --- .../java/org/bonitasoft/console/common/server/i18n/I18n.java | 2 +- .../org/bonitasoft/console/common/server/i18n/I18nTest.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/i18n/I18n.java b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/i18n/I18n.java index 363950db9eb..a6374acd4b8 100644 --- a/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/i18n/I18n.java +++ b/bpm/bonita-web-server/src/main/java/org/bonitasoft/console/common/server/i18n/I18n.java @@ -96,7 +96,7 @@ private TreeMap loadLocale(final LOCALE locale, List files public List getStreams(LOCALE locale) { ResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver(); try { - Resource[] resources = patternResolver.getResources("classpath:/i18n/" + getLocaleRegexForResource(locale)); + Resource[] resources = patternResolver.getResources("classpath*:i18n/" + getLocaleRegexForResource(locale)); List streams = new ArrayList<>(resources.length); for (Resource resource : resources) { InputStream stream = resource.getInputStream(); diff --git a/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/i18n/I18nTest.java b/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/i18n/I18nTest.java index 86bceb98839..9cededa0942 100644 --- a/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/i18n/I18nTest.java +++ b/bpm/bonita-web-server/src/test/java/org/bonitasoft/console/common/server/i18n/I18nTest.java @@ -30,13 +30,14 @@ public class I18nTest { @Test public void getStreams_should_read_from_classpath() { final List streams = I18n.getInstance().getStreams(AbstractI18n.LOCALE.fr); - assertThat(streams).hasSize(3); + //retrieving resources from both src/test/resources and src/main/resources + assertThat(streams).hasSize(6); assertThat(streams.get(0)).isNotNull(); } @Test public void getStreams_should_not_fail_if_no_resource_found() { - final List streams = I18n.getInstance().getStreams(AbstractI18n.LOCALE.es); + final List streams = I18n.getInstance().getStreams(AbstractI18n.LOCALE.de); assertThat(streams).isEmpty(); }