From 4311b167f3c3e218500aabe6b54c72f8799d0c04 Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Mon, 19 Apr 2021 17:07:47 +0200 Subject: [PATCH] Added unit test for UTF-8 encoded properties (#2295) Signed-off-by: Christoph Weitkamp --- .../i18n/TranslationProviderOSGiTest.java | 15 ++++++++++++--- .../i18n/otherResourceName_de_AT.properties | 1 + .../OH-INF/i18n/otherResourceName_en.properties | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_de_AT.properties diff --git a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/internal/i18n/TranslationProviderOSGiTest.java b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/internal/i18n/TranslationProviderOSGiTest.java index 814ef15e6b..34cafff653 100644 --- a/itests/org.openhab.core.tests/src/main/java/org/openhab/core/internal/i18n/TranslationProviderOSGiTest.java +++ b/itests/org.openhab.core.tests/src/main/java/org/openhab/core/internal/i18n/TranslationProviderOSGiTest.java @@ -52,7 +52,8 @@ public class TranslationProviderOSGiTest extends JavaOSGiTest { private static final String HELLO_MULTIPLE_NAMES_EN = "Hello openHAB, Hello thing, Hello rule!"; private static final String HELLO_MULTIPLE_NAMES_FR = "Bonjour openHAB, Bonjour thing, Bonjour rule!"; - private static final String BYE_DEFAULT = "Tschuess!"; + private static final String BYE_DE = "Tschüß!"; + private static final String BYE_EN = "Bye!"; TranslationProvider translationProvider; @@ -110,9 +111,13 @@ public class TranslationProviderOSGiTest extends JavaOSGiTest { assertThat(text, is(notNullValue())); assertThat(text, is(equalTo("default"))); + text = translationProvider.getText(bundle, KEY_BYE, "default", new Locale("de", "AT")); + assertThat(text, is(notNullValue())); + assertThat(text, is(equalTo(BYE_DE))); + text = translationProvider.getText(bundle, KEY_BYE, "default", Locale.ENGLISH); assertThat(text, is(notNullValue())); - assertThat(text, is(equalTo(BYE_DEFAULT))); + assertThat(text, is(equalTo(BYE_EN))); } @Test @@ -149,9 +154,13 @@ public class TranslationProviderOSGiTest extends JavaOSGiTest { assertThat(text, is(notNullValue())); assertThat(text, is(equalTo("default"))); + text = translationProvider.getText(bundle, KEY_BYE, "default", new Locale("de", "AT"), (Object[]) null); + assertThat(text, is(notNullValue())); + assertThat(text, is(equalTo(BYE_DE))); + text = translationProvider.getText(bundle, KEY_BYE, "default", Locale.ENGLISH, (Object[]) null); assertThat(text, is(notNullValue())); - assertThat(text, is(equalTo(BYE_DEFAULT))); + assertThat(text, is(equalTo(BYE_EN))); } @Test diff --git a/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_de_AT.properties b/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_de_AT.properties new file mode 100644 index 0000000000..4d9c9bb0c0 --- /dev/null +++ b/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_de_AT.properties @@ -0,0 +1 @@ +BYE = Tschüß! diff --git a/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_en.properties b/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_en.properties index 89e40164ec..5657b4341c 100644 --- a/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_en.properties +++ b/itests/org.openhab.core.tests/src/main/resources/OH-INF/i18n/otherResourceName_en.properties @@ -1 +1 @@ -BYE = Tschuess! +BYE = Bye!