aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness/src/test
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2012-06-22 14:04:44 +0200
committerFabrice Bellingard <bellingard@gmail.com>2012-06-22 14:04:44 +0200
commitbf998970a385d499990284f6db90ab1247d90029 (patch)
tree4cd109b5902e1d77ecdcb51f0fda1deb922072eb /sonar-testing-harness/src/test
parent60adc862836a9eae573587041ff35d090da55d38 (diff)
downloadsonarqube-bf998970a385d499990284f6db90ab1247d90029.tar.gz
sonarqube-bf998970a385d499990284f6db90ab1247d90029.zip
SONAR-3581 Tool to validate a l10n bundle based on multiple plugins
Diffstat (limited to 'sonar-testing-harness/src/test')
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java45
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/i18n/I18nMatchersTest.java52
-rw-r--r--sonar-testing-harness/src/test/resources/org/sonar/l10n/abacus_fr.properties28
3 files changed, 106 insertions, 19 deletions
diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java
index 8554d464aae..396f196927e 100644
--- a/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java
+++ b/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java
@@ -24,50 +24,56 @@ import org.junit.Test;
import org.sonar.test.TestUtils;
import java.io.File;
+import java.net.URI;
import java.util.SortedMap;
-import static org.hamcrest.Matchers.*;
-import static org.junit.Assert.*;
-import static org.sonar.test.i18n.I18nMatchers.isBundleUpToDate;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
public class BundleSynchronizedTest {
- private static final String GITHUB_RAW_FILE_PATH = "https://raw.github.com/SonarSource/sonar/master/sonar-testing-harness/src/test/resources/org/sonar/l10n/";
+ private static final String GITHUB_RAW_TESTING_FILE_PATH = "https://raw.github.com/SonarSource/sonar/master/sonar-testing-harness/src/test/resources/org/sonar/l10n/";
private BundleSynchronizedMatcher matcher;
@Before
- public void test() throws Exception {
- matcher = new BundleSynchronizedMatcher(null);
+ public void init() {
+ matcher = new BundleSynchronizedMatcher();
}
@Test
- // The case of a Sonar plugin that embeds all the bundles for every language
- public void testBundlesInsideSonarPlugin() {
+ // The case of a Sonar Language Pack that translates the Core bundles
+ public void shouldMatchBundlesOfLanguagePack() {
// synchronized bundle
- assertThat("myPlugin_fr_CA.properties", isBundleUpToDate());
- assertFalse(new File("target/l10n/myPlugin_fr_CA.properties.report.txt").exists());
+ assertThat("core_fr_CA.properties", new BundleSynchronizedMatcher(null, GITHUB_RAW_TESTING_FILE_PATH));
// missing keys
try {
- assertThat("myPlugin_fr.properties", isBundleUpToDate());
- assertTrue(new File("target/l10n/myPlugin_fr.properties.report.txt").exists());
+ assertThat("core_fr.properties", new BundleSynchronizedMatcher(null, GITHUB_RAW_TESTING_FILE_PATH));
} catch (AssertionError e) {
assertThat(e.getMessage(), containsString("Missing translations are:\nsecond.prop"));
}
}
@Test
- public void shouldNotFailIfNoMissingKeysButAdditionalKeys() {
- assertThat("noMissingKeys_fr.properties", isBundleUpToDate());
+ // The case of a Sonar Language Pack that translates plugin bundles
+ public void shouldMatchWithProvidedURI() throws Exception {
+ matcher = new BundleSynchronizedMatcher(new URI("http://svn.codehaus.org/sonar-plugins/tags/sonar-abacus-plugin-0.1/src/main/resources/org/sonar/l10n/abacus.properties"));
+ assertThat("abacus_fr.properties", matcher);
}
@Test
- // The case of a Sonar Language Pack that translates the Core bundles
- public void testBundlesOfLanguagePack() {
+ // The case of a Sonar plugin that embeds all the bundles for every language
+ public void testBundlesInsideSonarPlugin() {
// synchronized bundle
- assertThat("core_fr_CA.properties", new BundleSynchronizedMatcher(null, GITHUB_RAW_FILE_PATH));
+ assertThat("myPlugin_fr_CA.properties", matcher);
+ assertFalse(new File("target/l10n/myPlugin_fr_CA.properties.report.txt").exists());
// missing keys
try {
- assertThat("core_fr.properties", new BundleSynchronizedMatcher(null, GITHUB_RAW_FILE_PATH));
+ assertThat("myPlugin_fr.properties", matcher);
+ assertTrue(new File("target/l10n/myPlugin_fr.properties.report.txt").exists());
} catch (AssertionError e) {
assertThat(e.getMessage(), containsString("Missing translations are:\nsecond.prop"));
}
@@ -85,7 +91,7 @@ public class BundleSynchronizedTest {
@Test
public void testGetBundleFileFromGithub() throws Exception {
- matcher = new BundleSynchronizedMatcher(null, GITHUB_RAW_FILE_PATH);
+ matcher = new BundleSynchronizedMatcher(null, GITHUB_RAW_TESTING_FILE_PATH);
matcher.getBundleFileFromGithub("core.properties");
assertTrue(new File("target/l10n/download/core.properties").exists());
}
@@ -133,4 +139,5 @@ public class BundleSynchronizedTest {
assertThat(matcher.computeGitHubURL("core.properties", "2.10"),
is("https://raw.github.com/SonarSource/sonar/2.10/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties"));
}
+
}
diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/i18n/I18nMatchersTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/i18n/I18nMatchersTest.java
new file mode 100644
index 00000000000..c97cb3951e5
--- /dev/null
+++ b/sonar-testing-harness/src/test/java/org/sonar/test/i18n/I18nMatchersTest.java
@@ -0,0 +1,52 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2012 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.test.i18n;
+
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.hamcrest.Matchers.containsString;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.sonar.test.i18n.I18nMatchers.isBundleUpToDate;
+
+public class I18nMatchersTest {
+
+ @Test
+ public void testBundlesInsideSonarPlugin() {
+ // synchronized bundle
+ assertThat("myPlugin_fr_CA.properties", isBundleUpToDate());
+ assertFalse(new File("target/l10n/myPlugin_fr_CA.properties.report.txt").exists());
+ // missing keys
+ try {
+ assertThat("myPlugin_fr.properties", isBundleUpToDate());
+ assertTrue(new File("target/l10n/myPlugin_fr.properties.report.txt").exists());
+ } catch (AssertionError e) {
+ assertThat(e.getMessage(), containsString("Missing translations are:\nsecond.prop"));
+ }
+ }
+
+ @Test
+ public void shouldNotFailIfNoMissingKeysButAdditionalKeys() {
+ assertThat("noMissingKeys_fr.properties", isBundleUpToDate());
+ }
+}
diff --git a/sonar-testing-harness/src/test/resources/org/sonar/l10n/abacus_fr.properties b/sonar-testing-harness/src/test/resources/org/sonar/l10n/abacus_fr.properties
new file mode 100644
index 00000000000..03ee2266df9
--- /dev/null
+++ b/sonar-testing-harness/src/test/resources/org/sonar/l10n/abacus_fr.properties
@@ -0,0 +1,28 @@
+## -------- Test file for the BundleSynchronizedMatcher -------- ##
+widget.abacus.name=Abaques
+widget.abacus.description=Calcule la complexit\u00e9 de chaque composant pour vous aider \u00e0 utiliser vos abaques.
+
+widget.abacus.param.defaultColors=Liste de couleurs (format hexad\u00e9cimal) s\u00e9par\u00e9e par des virgules pour l'affichage du camembert.<br>Bien faire attention \u00e0 ce que le nombre de couleurs soit au minimum le m\u00eame que le nombre de niveaux de complexit\u00e9 des abaques.
+widget.abacus.param.defaultDisplay=Valeurs possibles :<ul class="bullet"><li>files (= nombre de fichiers)</li><li>percentage (= pourcentage)</li></ul>
+
+abacusTab.page=Abaques
+abacusTab.notComputed=Non calcul\u00e9e
+
+property.sonar.abacus.complexityThresholds.name=Seuils de complexit\u00e9 des abaques
+property.sonar.abacus.complexityThresholds.description=Usage : NomSeuil1:Complexit\u00e9Seuil1;NomSeuil2:Complexit\u00e9Seuil2;...;NomSeuilN<br>Valeur par d\u00e9faut : Simple:20;Medium:50;Complex:100;Very Complex
+
+metric.abacus-complexity.name=Complexit\u00e9 (Abaques)
+metric.abacus-complexity.description=Complexit\u00e9 (Abaques)
+metric.abacus-complexity-distribution.name=Distribution de la complexit\u00e9 (Abaques)
+metric.abacus-complexity-distribution.description=Distribution de la complexit\u00e9 (Abaques)
+
+abacus.componentComplexity=Complexit\u00e9 du composant
+abacus.componentComplexityDistribution.numberOfFiles=Distrib. complexit\u00e9 (fichiers)
+abacus.componentComplexityDistribution.percentage=Distrib. complexit\u00e9 (%)
+abacus.error.cannotDisplayWidget=Impossible d'afficher le widget.
+abacus.error.defaultColors.incorrectValue=La valeur du param\u00e8tre de wigdet <i>defaultColors</i> est incorrecte : moins de couleurs que de niveaux de complexit\u00e9 dans les abaques.
+abacus.error.defaultDisplay.incorrectValue=La valeur du param\u00e8tre de widget <i>defaultDisplay</i> est incorrecte : <i>{0}</i><br>Valeurs possibles :<ul class="bullet"><li>files (= nombre de fichiers)</li><li>percentage (= pourcentage)</li></ul>
+abacus.noData=Pas de donn\u00e9es
+abacus.numberOfFilesDistribution=Distribution en nombre de fichiers
+abacus.percentageDistribution=Distribution en %
+abacus.title=Abaques \ No newline at end of file