diff options
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 |