From c024588873d4b1b235b70371ec897b97d6e25fdb Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 3 Oct 2012 12:32:09 +0200 Subject: [PATCH] SONAR-3736 Fix regression (additional keys not displayed if any) --- .../org/sonar/test/i18n/BundleSynchronizedMatcher.java | 7 +++++++ .../org/sonar/test/i18n/BundleSynchronizedMatcherTest.java | 7 +++++++ .../test/resources/org/sonar/l10n/myPlugin_fr.properties | 3 ++- 3 files changed, 16 insertions(+), 1 deletion(-) 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 { // 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 @@ -57,6 +57,12 @@ public class BundleSynchronizedMatcherTest { assertFalse(new File("target/l10n/myPlugin_fr_CA.properties.report.txt").exists()); } + @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 { @@ -64,6 +70,7 @@ public class BundleSynchronizedMatcherTest { 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 -- 2.39.5