aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/test
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2011-06-13 10:40:52 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2011-06-13 10:40:52 +0200
commitaa92267c3ae906a14383c26ef2610ae358807115 (patch)
tree88e51ad2c7ad68b0faf55998dfa2e330741ee7e0 /sonar-server/src/test
parentc257dc801bcb060cb9a5c2f8c516607721bc57e4 (diff)
downloadsonarqube-aa92267c3ae906a14383c26ef2610ae358807115.tar.gz
sonarqube-aa92267c3ae906a14383c26ef2610ae358807115.zip
SONAR-75 Apply first version of contribution by www.serli.com
Diffstat (limited to 'sonar-server/src/test')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java b/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java
new file mode 100644
index 00000000000..fe150e2b754
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/ui/JRubyI18nTest.java
@@ -0,0 +1,51 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.server.ui;
+
+import org.hamcrest.core.Is;
+import org.junit.Test;
+import org.sonar.api.i18n.I18n;
+
+import java.util.Locale;
+
+import static org.hamcrest.core.IsNot.not;
+import static org.hamcrest.core.IsNull.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+
+public class JRubyI18nTest {
+ @Test
+ public void shouldConvertLocales() {
+ assertThat(JRubyI18n.toLocale("fr"), Is.is(Locale.FRENCH));
+ assertThat(JRubyI18n.toLocale("fr-CH"), Is.is(new Locale("fr", "CH")));
+ }
+
+ @Test
+ public void shouldCacheLocales() {
+ JRubyI18n i18n = new JRubyI18n(mock(I18n.class));
+ assertThat(i18n.getLocalesByRubyKey().size(), Is.is(0));
+
+ i18n.getLocale("fr");
+
+ assertThat(i18n.getLocalesByRubyKey().size(), Is.is(1));
+ assertThat(i18n.getLocalesByRubyKey().get("fr"), not(nullValue()));
+
+ }
+}