diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-02-19 13:07:11 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2017-02-19 13:07:11 +0100 |
commit | 4dcf22377c7823584f0d9d7dbb85641980245fd8 (patch) | |
tree | 28594d8d59c4f64deb7e3aa6f06f48b0e737cdb1 /sonar-testing-harness/src/main/java/org | |
parent | c3ae1aa643eb9edb168016bfadfbab3af9024962 (diff) | |
download | sonarqube-4dcf22377c7823584f0d9d7dbb85641980245fd8.tar.gz sonarqube-4dcf22377c7823584f0d9d7dbb85641980245fd8.zip |
Clean-up sonar-testing-harness dependencies
and decrease usages of Hamcrest
Diffstat (limited to 'sonar-testing-harness/src/main/java/org')
-rw-r--r-- | sonar-testing-harness/src/main/java/org/sonar/test/i18n/BundleSynchronizedMatcher.java | 19 | ||||
-rw-r--r-- | sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java | 12 |
2 files changed, 13 insertions, 18 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 0749a0fb5c0..90e9dd3b744 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 @@ -19,10 +19,6 @@ */ package org.sonar.test.i18n; -import org.apache.commons.io.IOUtils; -import org.hamcrest.BaseMatcher; -import org.hamcrest.Description; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -34,10 +30,12 @@ import java.util.Map; import java.util.Properties; import java.util.SortedMap; import java.util.TreeMap; +import org.apache.commons.io.IOUtils; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; -import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; public class BundleSynchronizedMatcher extends BaseMatcher<String> { @@ -152,21 +150,20 @@ public class BundleSynchronizedMatcher extends BaseMatcher<String> { protected static InputStream getBundleFileInputStream(String bundleName) { InputStream bundle = BundleSynchronizedMatcher.class.getResourceAsStream(L10N_PATH + bundleName); - assertThat("File '" + bundleName + "' does not exist in '/org/sonar/l10n/'.", bundle, notNullValue()); + assertNotNull("File '" + bundleName + "' does not exist in '/org/sonar/l10n/'.", bundle); return bundle; } protected static InputStream getDefaultBundleFileInputStream(String bundleName) { String defaultBundleName = extractDefaultBundleName(bundleName); InputStream bundle = BundleSynchronizedMatcher.class.getResourceAsStream(L10N_PATH + defaultBundleName); - assertThat("Default bundle '" + defaultBundleName + "' could not be found: add a dependency to the corresponding plugin in your POM.", bundle, notNullValue()); + assertNotNull("Default bundle '" + defaultBundleName + "' could not be found: add a dependency to the corresponding plugin in your POM.", bundle); return bundle; } protected static String extractDefaultBundleName(String bundleName) { int firstUnderScoreIndex = bundleName.indexOf('_'); - assertThat("The bundle '" + bundleName + "' is a default bundle (without locale), so it can't be compared.", firstUnderScoreIndex > 0, - is(true)); + assertTrue("The bundle '" + bundleName + "' is a default bundle (without locale), so it can't be compared.", firstUnderScoreIndex > 0); return bundleName.substring(0, firstUnderScoreIndex) + ".properties"; } diff --git a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java index b6428f1cb59..874215299d5 100644 --- a/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java +++ b/sonar-testing-harness/src/main/java/org/sonar/test/i18n/I18nMatchers.java @@ -19,15 +19,13 @@ */ package org.sonar.test.i18n; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.sonar.test.TestUtils; - import java.io.File; import java.net.URL; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import org.apache.commons.io.FileUtils; +import org.sonar.test.TestUtils; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; @@ -55,7 +53,7 @@ public final class I18nMatchers { fail("No bundle found in: " + BundleSynchronizedMatcher.L10N_PATH); } - Collection<File> bundles = FileUtils.listFiles(bundleFolder, new String[]{"properties"}, false); + Collection<File> bundles = FileUtils.listFiles(bundleFolder, new String[] {"properties"}, false); Map<String, String> failedAssertionMessages = new HashMap<>(); for (File bundle : bundles) { String bundleName = bundle.getName(); @@ -72,9 +70,9 @@ public final class I18nMatchers { StringBuilder message = new StringBuilder(); message.append(failedAssertionMessages.size()); message.append(" bundles are not up-to-date: "); - message.append(StringUtils.join(failedAssertionMessages.keySet(), ", ")); + message.append(String.join(", ", failedAssertionMessages.keySet())); message.append("\n\n"); - message.append(StringUtils.join(failedAssertionMessages.values(), "\n\n")); + message.append(String.join("\n\n", failedAssertionMessages.values())); fail(message.toString()); } } |