summaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness
diff options
context:
space:
mode:
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-10-03 12:32:09 +0200
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>2012-10-03 12:33:22 +0200
commitc024588873d4b1b235b70371ec897b97d6e25fdb (patch)
treeedf6eb8943a01f100be595fe75683791ae35e6be /sonar-testing-harness
parent62ec1ada6f9c17f4e20fc1905a1c98d67461be78 (diff)
downloadsonarqube-c024588873d4b1b235b70371ec897b97d6e25fdb.tar.gz
sonarqube-c024588873d4b1b235b70371ec897b97d6e25fdb.zip
SONAR-3736 Fix regression (additional keys not displayed if any)
Diffstat (limited to 'sonar-testing-harness')
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java7
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedMatcherTest.java7
-rw-r--r--sonar-testing-harness/src/test/resources/org/sonar/l10n/myPlugin_fr.properties3
3 files changed, 16 insertions, 1 deletions
diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
index ca49bcec1de..4ccd121179c 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java
@@ -60,8 +60,15 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> {
// and now let's compare!
try {
+ // search for missing keys
missingKeys = retrieveMissingTranslations(bundleInputStream, defaultBundleInputStream);
+
+ // and now for additional keys
+ bundleInputStream = getBundleFileInputStream(bundleName);
+ defaultBundleInputStream = getDefaultBundleFileInputStream(bundleName);
additionalKeys = retrieveMissingTranslations(defaultBundleInputStream, bundleInputStream);
+
+ // And fail only if there are missing keys
return missingKeys.isEmpty();
} catch (IOException e) {
fail("An error occured while reading the bundles: " + e.getMessage());
diff --git a/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedMatcherTest.java b/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedMatcherTest.java
index 2eb97a82a6e..8795c79304f 100644
--- a/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedMatcherTest.java
+++ b/sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedMatcherTest.java
@@ -58,12 +58,19 @@ public class BundleSynchronizedMatcherTest {
}
@Test
+ public void shouldMatchEvenWithAdditionalKeys() {
+ assertThat("myPlugin_fr_QB.properties", matcher);
+ assertFalse(new File("target/l10n/myPlugin_fr_CA.properties.report.txt").exists());
+ }
+
+ @Test
public void shouldNotMatch() {
try {
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"));
+ assertThat(e.getMessage(), containsString("The following translations do not exist in the reference bundle:\nfourth.prop"));
}
}
diff --git a/sonar-testing-harness/src/test/resources/org/sonar/l10n/myPlugin_fr.properties b/sonar-testing-harness/src/test/resources/org/sonar/l10n/myPlugin_fr.properties
index 79c32ed5e81..cd5063e7701 100644
--- a/sonar-testing-harness/src/test/resources/org/sonar/l10n/myPlugin_fr.properties
+++ b/sonar-testing-harness/src/test/resources/org/sonar/l10n/myPlugin_fr.properties
@@ -1,4 +1,5 @@
## -------- Test file for the BundleSynchronizedMatcher -------- ##
first.prop = C'est ma première propriété
#second.prop = C'est ma deuxième propriété
-third.prop = C'est ma troisième propriété \ No newline at end of file
+third.prop = C'est ma troisième propriété
+fourth.prop = C'est ma quatrième propriété \ No newline at end of file