From a25c70784c67abebca9df2825362836df1ac584f Mon Sep 17 00:00:00 2001 From: Daniel Fesenmeyer Date: Tue, 22 Jun 2021 20:10:00 +0200 Subject: [PATCH] KEYCLOAK-18467 support unicode for realm localization texts --- .../RealmLocalizationTextsEntity.java | 3 ++ .../META-INF/jpa-changelog-15.0.0.xml | 36 +++++++++++++++++++ .../META-INF/jpa-changelog-master.xml | 1 + .../testsuite/i18n/RealmLocalizationTest.java | 29 +++++++++++++++ 4 files changed, 69 insertions(+) create mode 100644 model/jpa/src/main/resources/META-INF/jpa-changelog-15.0.0.xml create mode 100644 testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/RealmLocalizationTest.java diff --git a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmLocalizationTextsEntity.java b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmLocalizationTextsEntity.java index 66b9ea97ec..3be11da39a 100644 --- a/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmLocalizationTextsEntity.java +++ b/model/jpa/src/main/java/org/keycloak/models/jpa/entities/RealmLocalizationTextsEntity.java @@ -27,6 +27,8 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.IdClass; import javax.persistence.Table; + +import org.hibernate.annotations.Nationalized; import org.keycloak.models.jpa.converter.MapStringConverter; @Entity @@ -81,6 +83,7 @@ public class RealmLocalizationTextsEntity { @Column(name = "LOCALE") private String locale; + @Nationalized @Column(name = "TEXTS") private String texts; // TODO: The @Convert does not work as expected on quarkus. It doesn't update the "texts" in case that updated map has same keys (but different values) as old map had diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-15.0.0.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-15.0.0.xml new file mode 100644 index 0000000000..6215dd4a59 --- /dev/null +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-15.0.0.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml b/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml index 66f9797ffa..2509294c07 100755 --- a/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml +++ b/model/jpa/src/main/resources/META-INF/jpa-changelog-master.xml @@ -70,5 +70,6 @@ + diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/RealmLocalizationTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/RealmLocalizationTest.java new file mode 100644 index 0000000000..70957ee5f1 --- /dev/null +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/i18n/RealmLocalizationTest.java @@ -0,0 +1,29 @@ +package org.keycloak.testsuite.i18n; + +import org.junit.Test; +import org.keycloak.admin.client.resource.RealmLocalizationResource; + +import java.util.Map; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasEntry; + +public class RealmLocalizationTest extends AbstractI18NTest { + + /** + * Make sure that realm localization texts support unicode (). + */ + @Test + public void realmLocalizationTextsSupportUnicode() { + String locale = "en"; + String key = "Äǜṳǚǘǖ"; + String text = "Öṏṏ"; + RealmLocalizationResource localizationResource = testRealm().localization(); + localizationResource.saveRealmLocalizationText(locale, key, text); + + Map localizationTexts = localizationResource.getRealmLocalizationTexts(locale); + + assertThat(localizationTexts, hasEntry(key, text)); + } + +}