diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-20 00:43:47 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-06-20 00:45:34 +0200 |
commit | 2f779df51e9da5b07ad6f837fe1c98eab9fbf439 (patch) | |
tree | d2be9202eb947ecb005c72368bbcb4f1b86e8e68 /sonar-testing-harness | |
parent | 24ec2501f751dc2a122f1e5f905ee4151ec8b891 (diff) | |
download | sonarqube-2f779df51e9da5b07ad6f837fe1c98eab9fbf439.tar.gz sonarqube-2f779df51e9da5b07ad6f837fe1c98eab9fbf439.zip |
Upgrade hamcrest and fix conflicts with JUnit and Mockito
Diffstat (limited to 'sonar-testing-harness')
-rw-r--r-- | sonar-testing-harness/pom.xml | 8 | ||||
-rw-r--r-- | sonar-testing-harness/src/test/java/org/sonar/test/i18n/BundleSynchronizedMatcherTest.java | 45 |
2 files changed, 29 insertions, 24 deletions
diff --git a/sonar-testing-harness/pom.xml b/sonar-testing-harness/pom.xml index 65d7a16745a..a3b68ab6bbe 100644 --- a/sonar-testing-harness/pom.xml +++ b/sonar-testing-harness/pom.xml @@ -17,10 +17,6 @@ <artifactId>fest-assert</artifactId> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - </dependency> - <dependency> <groupId>org.skyscreamer</groupId> <artifactId>jsonassert</artifactId> </dependency> @@ -33,6 +29,10 @@ <artifactId>junit</artifactId> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + </dependency> + <dependency> <!-- used only for org.sonar.test.channel classes --> <groupId>org.codehaus.sonar</groupId> <artifactId>sonar-channel</artifactId> 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 b2e626937c0..ac269beba56 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 @@ -31,20 +31,16 @@ import java.io.IOException; import java.io.InputStream; import java.util.SortedMap; -import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.hasItem; -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 junit.framework.TestCase.fail; +import static org.hamcrest.Matchers.*; +import static org.junit.Assert.*; public class BundleSynchronizedMatcherTest { @Rule public ExpectedException thrown = ExpectedException.none(); - private BundleSynchronizedMatcher matcher; + BundleSynchronizedMatcher matcher; @Before public void init() { @@ -76,26 +72,31 @@ public class BundleSynchronizedMatcherTest { @Test public void shouldNotMatchIfNotString() { - assertThat(matcher.matches(3)).isFalse(); + assertThat(matcher.matches(3), is(false)); } @Test public void testGetBundleFileFromClasspath() { // OK - assertThat(BundleSynchronizedMatcher.getBundleFileInputStream("myPlugin_fr.properties")) - .isNotNull(); + assertThat(BundleSynchronizedMatcher.getBundleFileInputStream("myPlugin_fr.properties"), notNullValue()); // KO - thrown.expect(AssertionError.class); - thrown.expectMessage("File 'unexistingBundle.properties' does not exist in '/org/sonar/l10n/'."); - BundleSynchronizedMatcher.getBundleFileInputStream("unexistingBundle.properties"); + try { + BundleSynchronizedMatcher.getBundleFileInputStream("unexistingBundle.properties"); + fail(); + } catch (AssertionError e) { + assertThat(e.getMessage(), startsWith("File 'unexistingBundle.properties' does not exist in '/org/sonar/l10n/'.")); + } } @Test public void testGetDefaultBundleFileFromClasspath() { - thrown.expect(AssertionError.class); - thrown.expectMessage("Default bundle 'unexistingBundle.properties' could not be found: add a dependency to the corresponding plugin in your POM."); - BundleSynchronizedMatcher.getDefaultBundleFileInputStream("unexistingBundle_fr.properties"); + try { + BundleSynchronizedMatcher.getDefaultBundleFileInputStream("unexistingBundle_fr.properties"); + fail(); + } catch (AssertionError e) { + assertThat(e.getMessage(), startsWith("Default bundle 'unexistingBundle.properties' could not be found: add a dependency to the corresponding plugin in your POM.")); + } } @Test @@ -105,9 +106,13 @@ public class BundleSynchronizedMatcherTest { assertThat(BundleSynchronizedMatcher.extractDefaultBundleName("myPlugin_fr_QB.properties"), is("myPlugin.properties")); // KO - thrown.expect(AssertionError.class); - thrown.expectMessage("The bundle 'myPlugin.properties' is a default bundle (without locale), so it can't be compared."); - BundleSynchronizedMatcher.extractDefaultBundleName("myPlugin.properties"); + + try { + BundleSynchronizedMatcher.extractDefaultBundleName("myPlugin.properties"); + fail(); + } catch (AssertionError e) { + assertThat(e.getMessage(), startsWith("The bundle 'myPlugin.properties' is a default bundle (without locale), so it can't be compared.")); + } } @Test |