Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Motsch2018-04-26 09:18:48 +0000
committerIvan Motsch2018-04-27 22:32:16 +0000
commit169db56725780697bbd0495b745b949707109d36 (patch)
tree78181e12ea380f4b4f40899f76ea471e97a9612e /org.eclipse.scout.rt.platform.test
parent5ad8ad4c66692d868a160873d79bd845d3767948 (diff)
downloadorg.eclipse.scout.rt-169db56725780697bbd0495b745b949707109d36.tar.gz
org.eclipse.scout.rt-169db56725780697bbd0495b745b949707109d36.tar.xz
org.eclipse.scout.rt-169db56725780697bbd0495b745b949707109d36.zip
Moved text and multi-language support from shared to platform
The scout multi-language text support mainly is ITextProviderService, AbstractDynamicNlsTextProviderService and the convenience accessor TEXTS. This facility was moved from org.eclipse.scout.rt.shared to org.eclipse.scout.rt.platform.text Change-Id: I3c2d2c9a92163f71263f1ac3a39d7c5515b96d65 Signed-off-by: Ivan Motsch <ivan.motsch@bsiag.com> Reviewed-on: https://git.eclipse.org/r/121812 Tested-by: CI Bot
Diffstat (limited to 'org.eclipse.scout.rt.platform.test')
-rw-r--r--org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/HTMLTextTest.java32
-rw-r--r--org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TestTextProviderService.java24
-rw-r--r--org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TextsTest.java49
-rw-r--r--org.eclipse.scout.rt.platform.test/src/test/resources/org/eclipse/scout/rt/platform/test/Texts.properties17
4 files changed, 122 insertions, 0 deletions
diff --git a/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/HTMLTextTest.java b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/HTMLTextTest.java
new file mode 100644
index 0000000000..e20499e5b3
--- /dev/null
+++ b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/HTMLTextTest.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2017 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.platform.text;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.scout.rt.platform.html.HTML;
+import org.eclipse.scout.rt.platform.html.IHtmlContent;
+import org.eclipse.scout.rt.testing.platform.runner.PlatformTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests for {@link HTML} with Texts containing links.
+ */
+@RunWith(PlatformTestRunner.class)
+public class HTMLTextTest {
+
+ @Test
+ public void testBoldHtmlText() {
+ IHtmlContent boldText = HTML.bold(HTML.raw(TEXTS.get("key6", HTML.appLink("REF", "text").toHtml())));
+ assertEquals("<b>value <span class=\"app-link\" data-ref=\"REF\">text</span></b>", boldText.toHtml());
+ }
+}
diff --git a/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TestTextProviderService.java b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TestTextProviderService.java
new file mode 100644
index 0000000000..f60ef1be50
--- /dev/null
+++ b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TestTextProviderService.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2016 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.platform.text;
+
+import org.eclipse.scout.rt.platform.Order;
+
+/**
+ * Text provider service for texts used by org.eclipse.scout.rt.shared.test plugin.
+ */
+@Order(5400)
+public class TestTextProviderService extends AbstractDynamicNlsTextProviderService {
+ @Override
+ public String getDynamicNlsBaseName() {
+ return "org.eclipse.scout.rt.platform.test.Texts";
+ }
+}
diff --git a/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TextsTest.java b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TextsTest.java
new file mode 100644
index 0000000000..eb8be42ad0
--- /dev/null
+++ b/org.eclipse.scout.rt.platform.test/src/test/java/org/eclipse/scout/rt/platform/text/TextsTest.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2017 BSI Business Systems Integration AG.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * BSI Business Systems Integration AG - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.scout.rt.platform.text;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.util.Locale;
+import java.util.Map;
+
+import org.eclipse.scout.rt.platform.BEANS;
+import org.eclipse.scout.rt.testing.platform.runner.PlatformTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * JUnit tests for {@link ScoutTexts} and {@link TEXTS}
+ */
+@RunWith(PlatformTestRunner.class)
+public class TextsTest {
+
+ @Test
+ public void testGet() {
+ assertEquals("Value 1", TEXTS.get("key1"));
+ assertEquals("{undefined text anyKey}", TEXTS.get("anyKey"));
+ }
+
+ @Test
+ public void testGetWithFallback() {
+ assertEquals("Value 2", TEXTS.getWithFallback("key2", "fallback"));
+ assertEquals("fallback", TEXTS.getWithFallback("anyKey", "fallback"));
+ assertNull(TEXTS.getWithFallback("anyKey", null));
+ }
+
+ @Test
+ public void testGetTextMap() {
+ Map<String, String> textMap = BEANS.get(ScoutTexts.class).getTextMap(Locale.ENGLISH);
+ assertNotNull(textMap);
+ }
+}
diff --git a/org.eclipse.scout.rt.platform.test/src/test/resources/org/eclipse/scout/rt/platform/test/Texts.properties b/org.eclipse.scout.rt.platform.test/src/test/resources/org/eclipse/scout/rt/platform/test/Texts.properties
new file mode 100644
index 0000000000..0b08dfdf5a
--- /dev/null
+++ b/org.eclipse.scout.rt.platform.test/src/test/resources/org/eclipse/scout/rt/platform/test/Texts.properties
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2010-2015 BSI Business Systems Integration AG.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# BSI Business Systems Integration AG - initial API and implementation
+#
+
+key1=Value 1
+key2=Value 2
+key3=Value 3
+key4=Value 4
+key5=Value 5
+key6=value {0}

Back to the top