aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-testing-harness/src/test
diff options
context:
space:
mode:
authorFabrice Bellingard <bellingard@gmail.com>2011-09-02 18:03:38 +0200
committerFabrice Bellingard <bellingard@gmail.com>2011-09-02 18:03:38 +0200
commit7df9484047b3d1d58d5b142e4042728a01512026 (patch)
tree189ad52ef4583615e7c87cf886128b10cd6f0732 /sonar-testing-harness/src/test
parentf0559fe73cd8d29a5f505c5a80c0c6784b97430c (diff)
downloadsonarqube-7df9484047b3d1d58d5b142e4042728a01512026.tar.gz
sonarqube-7df9484047b3d1d58d5b142e4042728a01512026.zip
SONAR-2693 Improve unit tests for I18n Harmcrest matcher
Diffstat (limited to 'sonar-testing-harness/src/test')
-rw-r--r--sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedTest.java21
-rw-r--r--sonar-testing-harness/src/test/resources/org/sonar/l10n/core_fr_CA.properties4
2 files changed, 19 insertions, 6 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 0bac5a9047b..73d6e310689 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
@@ -31,17 +31,17 @@ import java.io.File;
import java.util.Collection;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.sonar.test.TestUtils;
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 BundleSynchronizedMatcher matcher;
@Before
public void test() throws Exception {
- matcher = new BundleSynchronizedMatcher("https://raw.github.com/SonarSource/sonar/master/sonar-testing-harness/src/test/resources/org/sonar/l10n/");
+ matcher = new BundleSynchronizedMatcher();
}
@Test
@@ -49,25 +49,34 @@ public class BundleSynchronizedTest {
public void testBundlesInsideSonarPlugin() {
// synchronized bundle
assertThat("myPlugin_fr_CA.properties", isBundleSynchronized());
+ assertFalse(new File("target/l10n/myPlugin_fr_CA.properties.report.txt").exists());
// missing keys
try {
assertThat("myPlugin_fr.properties", isBundleSynchronized());
+ 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());
+ assertTrue(new File("target/l10n/myPlugin_fr_QB.properties.report.txt").exists());
} catch (AssertionError e) {
- assertThat(e.getMessage(), containsString("Also, the following keys do not exist in the default bundle:\n\t- fourth.prop"));
+ assertThat(e.getMessage(), containsString("The following keys do not exist in the default bundle:\n\t- fourth.prop"));
}
}
@Test
- @Ignore
// The case of a Sonar Language Pack that translates the Core bundles
public void testBundlesOfLanguagePack() {
- assertThat("core_fr.properties", isBundleSynchronized());
+ // synchronized bundle
+ assertThat("core_fr_CA.properties", new BundleSynchronizedMatcher(GITHUB_RAW_FILE_PATH));
+ // missing keys
+ try {
+ assertThat("core_fr.properties", new BundleSynchronizedMatcher(GITHUB_RAW_FILE_PATH));
+ } catch (AssertionError e) {
+ assertThat(e.getMessage(), containsString("Missing keys are:\n\t- second.prop"));
+ }
}
@Test
@@ -81,8 +90,8 @@ public class BundleSynchronizedTest {
}
@Test
- @Ignore
public void testGetBundleFileFromGithub() throws Exception {
+ matcher = new BundleSynchronizedMatcher(GITHUB_RAW_FILE_PATH);
matcher.getBundleFileFromGithub("core.properties");
assertTrue(new File("target/l10n/download/core.properties").exists());
}
diff --git a/sonar-testing-harness/src/test/resources/org/sonar/l10n/core_fr_CA.properties b/sonar-testing-harness/src/test/resources/org/sonar/l10n/core_fr_CA.properties
new file mode 100644
index 00000000000..d182159860d
--- /dev/null
+++ b/sonar-testing-harness/src/test/resources/org/sonar/l10n/core_fr_CA.properties
@@ -0,0 +1,4 @@
+## -------- Test file for the BundleSynchronizedMatcher -------- ##
+first.prop = This is my first property
+second.prop = This is my second property
+third.prop = This is my third property \ No newline at end of file