diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-09-02 18:03:38 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-09-02 18:03:38 +0200 |
commit | 7df9484047b3d1d58d5b142e4042728a01512026 (patch) | |
tree | 189ad52ef4583615e7c87cf886128b10cd6f0732 /sonar-testing-harness/src/main | |
parent | f0559fe73cd8d29a5f505c5a80c0c6784b97430c (diff) | |
download | sonarqube-7df9484047b3d1d58d5b142e4042728a01512026.tar.gz sonarqube-7df9484047b3d1d58d5b142e4042728a01512026.zip |
SONAR-2693 Improve unit tests for I18n Harmcrest matcher
Diffstat (limited to 'sonar-testing-harness/src/main')
-rw-r--r-- | sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java | 23 |
1 files changed, 22 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 1fd44ecfa6b..18351b9c70b 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 @@ -28,6 +28,7 @@ import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; +import java.io.FileWriter; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -35,6 +36,7 @@ import java.util.Collection; import java.util.Properties; import java.util.Set; +import org.apache.commons.io.IOUtils; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.sonar.test.TestUtils; @@ -102,16 +104,35 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> { } } if ( !nonExistingKeys.isEmpty()) { - details.append("\n\nAlso, the following keys do not exist in the default bundle:"); + details.append("\n\nThe following keys do not exist in the default bundle:"); for (String key : nonExistingKeys) { details.append("\n\t- " + key); } } details.append("\n\n======================="); + printReport(details.toString()); + description.appendText(details.toString()); } + private void printReport(String details) { + File dumpFile = new File("target/l10n/" + bundleName + ".report.txt"); + if (dumpFile.exists()) { + dumpFile.delete(); + } + dumpFile.getParentFile().mkdirs(); + FileWriter writer = null; + try { + writer = new FileWriter(dumpFile); + writer.write(details); + } catch (IOException e) { + System.out.println("Unable to write the report to 'target/l10n/" + bundleName + ".report.txt'."); + } finally { + IOUtils.closeQuietly(writer); + } + } + protected Collection<String> retrieveMissingKeys(File bundle, File defaultBundle) throws IOException { Collection<String> missingKeys = Lists.newArrayList(); |