aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness/src/test
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-09-08 14:21:19 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-09-08 14:23:30 +0200
commitcf9829861fca004f21640c27d692adb064b0f098 (patch)
tree25c8ef4f4f4b1b528203bbcb180c92ca49af7fce /sonar-testing-harness/src/test
parentae6cd424cdfce583739a61ffc387aa8efc04cb2d (diff)
downloadsonarqube-cf9829861fca004f21640c27d692adb064b0f098.tar.gz
sonarqube-cf9829861fca004f21640c27d692adb064b0f098.zip
SONAR-2693 Improve I18n Harmcrest matcher
- #isBundleSynchronized replace by #isBundleUpToDate - #assertAllBundlesUpToDate static method added to avoid specifying files one by one - if bundles are Core bundles translations, then the original bundles are searched on Github using the Sonar version specified by the "sonar.version" property in the POM
Diffstat (limited to 'sonar-testing-harness/src/test')
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java20
-rw-r--r--sonar-testing-harness/src/test/resources/version.properties2
2 files changed, 18 insertions, 4 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 73d6e310689..3edc655ddfd 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
@@ -25,7 +25,7 @@ import static org.hamcrest.Matchers.is;
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.isBundleSynchronized;
+import static org.sonar.test.i18n.I18nMatchers.isBundleUpToDate;
import java.io.File;
import java.util.Collection;
@@ -48,18 +48,18 @@ public class BundleSynchronizedTest {
// The case of a Sonar plugin that embeds all the bundles for every language
public void testBundlesInsideSonarPlugin() {
// synchronized bundle
- assertThat("myPlugin_fr_CA.properties", isBundleSynchronized());
+ 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", isBundleSynchronized());
+ assertThat("myPlugin_fr.properties", isBundleUpToDate());
assertTrue(new File("target/l10n/myPlugin_fr.properties.report.txt").exists());
} catch (AssertionError e) {
assertThat(e.getMessage(), containsString("Missing keys are:\n\t- second.prop"));
}
// unnecessary many keys
try {
- assertThat("myPlugin_fr_QB.properties", isBundleSynchronized());
+ assertThat("myPlugin_fr_QB.properties", isBundleUpToDate());
assertTrue(new File("target/l10n/myPlugin_fr_QB.properties.report.txt").exists());
} catch (AssertionError e) {
assertThat(e.getMessage(), containsString("The following keys do not exist in the default bundle:\n\t- fourth.prop"));
@@ -127,4 +127,16 @@ public class BundleSynchronizedTest {
diffs = matcher.retrieveMissingKeys(qbBundle, defaultBundle);
assertThat(diffs.size(), is(0));
}
+
+ @Test
+ public void testComputeGitHubURL() throws Exception {
+ assertThat(
+ matcher.computeGitHubURL("core.properties", null),
+ is("https://raw.github.com/SonarSource/sonar/master/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties"));
+ assertThat(
+ matcher.computeGitHubURL("core.properties", "2.11-SNAPSHOT"),
+ is("https://raw.github.com/SonarSource/sonar/master/plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties"));
+ 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/resources/version.properties b/sonar-testing-harness/src/test/resources/version.properties
new file mode 100644
index 00000000000..f57ea3a66e4
--- /dev/null
+++ b/sonar-testing-harness/src/test/resources/version.properties
@@ -0,0 +1,2 @@
+# The version here in this test file does not matter as the Harmcrest matcher will always look at master if there's a "-SNAPSHOT" suffix
+sonar.version=2.11-SNAPSHOT \ No newline at end of file