diff options
102 files changed, 267 insertions, 244 deletions
diff --git a/plugins/sonar-core-plugin/pom.xml b/plugins/sonar-core-plugin/pom.xml index 0361cb6cfcb..8214ce000e3 100644 --- a/plugins/sonar-core-plugin/pom.xml +++ b/plugins/sonar-core-plugin/pom.xml @@ -71,7 +71,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java index 4f52830b5de..86b43609ec6 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/UnitTestDecoratorTest.java @@ -19,6 +19,7 @@ */ package org.sonar.plugins.core.sensors; +import org.hamcrest.Matchers; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; @@ -31,7 +32,6 @@ import org.sonar.api.resources.Project; import java.util.Arrays; import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.Matchers.closeTo; import static org.mockito.Matchers.doubleThat; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; @@ -82,7 +82,7 @@ public class UnitTestDecoratorTest { verify(context).saveMeasure(eq(CoreMetrics.TEST_FAILURES), eq(2.0)); verify(context).saveMeasure(eq(CoreMetrics.SKIPPED_TESTS), eq(2.0)); verify(context).saveMeasure(eq(CoreMetrics.TEST_EXECUTION_TIME), eq(2.0)); - verify(context).saveMeasure(eq(CoreMetrics.TEST_SUCCESS_DENSITY), doubleThat(closeTo(33.3, 0.1))); + verify(context).saveMeasure(eq(CoreMetrics.TEST_SUCCESS_DENSITY), doubleThat(Matchers.closeTo(33.3, 0.1))); } private void mockChildrenMeasures(Metric metric, double value) { diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java index 7a2c47d57a1..ce7cc6cf5dd 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java @@ -36,7 +36,7 @@ import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Matchers.anyList; import static org.mockito.Mockito.mock; diff --git a/plugins/sonar-cpd-plugin/pom.xml b/plugins/sonar-cpd-plugin/pom.xml index 13fbe452140..aa992e547f9 100644 --- a/plugins/sonar-cpd-plugin/pom.xml +++ b/plugins/sonar-cpd-plugin/pom.xml @@ -44,8 +44,14 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> + + <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java index 7ebae1da257..0c733e9227a 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java @@ -27,8 +27,8 @@ import org.sonar.api.resources.File; import org.sonar.api.resources.Qualifiers; import org.sonar.api.test.IsMeasure; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.argThat; diff --git a/plugins/sonar-dbcleaner-plugin/pom.xml b/plugins/sonar-dbcleaner-plugin/pom.xml index 38388e21c4d..23d11cd36f0 100644 --- a/plugins/sonar-dbcleaner-plugin/pom.xml +++ b/plugins/sonar-dbcleaner-plugin/pom.xml @@ -47,6 +47,11 @@ <artifactId>junit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> <!-- TODO http://jira.codehaus.org/browse/SONAR-2011 We need following dependency, otherwise we will receive @@ -60,7 +65,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> </dependencies> diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilterTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilterTest.java index 744c88cccef..5367c3675b8 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilterTest.java +++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/DeleteAllFilterTest.java @@ -29,7 +29,7 @@ import java.util.List; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; +import static org.hamcrest.Matchers.hasItem; public class DeleteAllFilterTest { diff --git a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneFilterTest.java b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneFilterTest.java index e9faa55c7b9..cd1624644a5 100644 --- a/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneFilterTest.java +++ b/plugins/sonar-dbcleaner-plugin/src/test/java/org/sonar/plugins/dbcleaner/period/KeepOneFilterTest.java @@ -19,8 +19,8 @@ */ package org.sonar.plugins.dbcleaner.period; +import org.hamcrest.core.IsCollectionContaining; import org.junit.Test; -import org.junit.internal.matchers.IsCollectionContaining; import org.sonar.api.utils.DateUtils; import org.sonar.core.purge.PurgeableSnapshotDto; import org.sonar.plugins.dbcleaner.DbCleanerTestUtils; @@ -46,7 +46,7 @@ public class KeepOneFilterTest { createSnapshotWithDate(4L, "2011-05-19"), // may -> to be deleted createSnapshotWithDate(5L, "2011-06-01"), // june -> keep createSnapshotWithDate(6L, "2012-01-01") // out of scope -> keep - )); + )); assertThat(toDelete.size(), is(2)); assertThat(toDelete, IsCollectionContaining.hasItem(new DbCleanerTestUtils.SnapshotMatcher(3L))); @@ -62,7 +62,7 @@ public class KeepOneFilterTest { createSnapshotWithDate(2L, "2011-05-02").setLast(true), createSnapshotWithDate(3L, "2011-05-19").setHasEvents(true).setLast(false), createSnapshotWithDate(4L, "2011-05-23") // to be deleted - )); + )); assertThat(toDelete.size(), is(2)); assertThat(toDelete, IsCollectionContaining.hasItem(new DbCleanerTestUtils.SnapshotMatcher(1L))); diff --git a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java index a6ee36b8ba6..336889f2f81 100644 --- a/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java +++ b/plugins/sonar-design-plugin/src/test/java/org/sonar/plugins/design/DesignPluginTest.java @@ -19,7 +19,7 @@ */ package org.sonar.plugins.design; -import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/plugins/sonar-email-notifications-plugin/pom.xml b/plugins/sonar-email-notifications-plugin/pom.xml index bca732f4fb5..6492f44fb1f 100644 --- a/plugins/sonar-email-notifications-plugin/pom.xml +++ b/plugins/sonar-email-notifications-plugin/pom.xml @@ -36,7 +36,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/plugins/sonar-l10n-en-plugin/pom.xml b/plugins/sonar-l10n-en-plugin/pom.xml index 4018b3a905e..bc1cc822cc6 100644 --- a/plugins/sonar-l10n-en-plugin/pom.xml +++ b/plugins/sonar-l10n-en-plugin/pom.xml @@ -51,7 +51,11 @@ <artifactId>fest-assert</artifactId> <scope>test</scope> </dependency> - + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> @@ -907,8 +907,14 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <version>1.9.5</version> + <exclusions> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>org.easytesting</groupId> @@ -916,11 +922,6 @@ <version>1.4</version> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <version>1.1</version> - </dependency> - <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> <version>1.3.1</version> @@ -1049,9 +1050,20 @@ <version>1.2.2</version> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <version>1.3</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> - <version>4.10</version> + <version>4.11</version> + <exclusions> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>xmlunit</groupId> diff --git a/sonar-application/pom.xml b/sonar-application/pom.xml index 4340d3dc57d..1c8ffbf1eab 100644 --- a/sonar-application/pom.xml +++ b/sonar-application/pom.xml @@ -193,13 +193,18 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.easytesting</groupId> <artifactId>fest-assert</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-application/src/test/java/org/sonar/application/ConfigurationUtilsTest.java b/sonar-application/src/test/java/org/sonar/application/ConfigurationUtilsTest.java index 29a722b9fad..133505a51c7 100644 --- a/sonar-application/src/test/java/org/sonar/application/ConfigurationUtilsTest.java +++ b/sonar-application/src/test/java/org/sonar/application/ConfigurationUtilsTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import java.util.Map; import java.util.Properties; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class ConfigurationUtilsTest { diff --git a/sonar-application/src/test/java/org/sonar/application/EncryptionTest.java b/sonar-application/src/test/java/org/sonar/application/EncryptionTest.java index 85b3c568a35..80bc4f1d819 100644 --- a/sonar-application/src/test/java/org/sonar/application/EncryptionTest.java +++ b/sonar-application/src/test/java/org/sonar/application/EncryptionTest.java @@ -22,7 +22,7 @@ package org.sonar.application; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class EncryptionTest { diff --git a/sonar-application/src/test/java/org/sonar/application/LoggingTest.java b/sonar-application/src/test/java/org/sonar/application/LoggingTest.java index 1e5743daa33..1ff7b194d56 100644 --- a/sonar-application/src/test/java/org/sonar/application/LoggingTest.java +++ b/sonar-application/src/test/java/org/sonar/application/LoggingTest.java @@ -33,6 +33,7 @@ import org.mockito.Mockito; import org.slf4j.Logger; import java.io.File; +import java.io.IOException; import java.util.Properties; import static org.mockito.Matchers.argThat; @@ -47,7 +48,7 @@ public class LoggingTest { public TemporaryFolder temp = new TemporaryFolder(); @Before - public void setHome() { + public void setHome() throws IOException { File homeDir = temp.newFolder("home"); System.setProperty("SONAR_HOME", homeDir.getAbsolutePath()); } diff --git a/sonar-application/src/test/java/org/sonar/application/StartServerTest.java b/sonar-application/src/test/java/org/sonar/application/StartServerTest.java index 56de4ab9a3d..33bdd787db5 100644 --- a/sonar-application/src/test/java/org/sonar/application/StartServerTest.java +++ b/sonar-application/src/test/java/org/sonar/application/StartServerTest.java @@ -27,7 +27,6 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import java.io.File; -import java.io.IOException; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; diff --git a/sonar-application/src/test/java/org/sonar/application/WebappTest.java b/sonar-application/src/test/java/org/sonar/application/WebappTest.java index dc7d605cc68..ccfe6d3fb52 100644 --- a/sonar-application/src/test/java/org/sonar/application/WebappTest.java +++ b/sonar-application/src/test/java/org/sonar/application/WebappTest.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import java.io.File; +import java.io.IOException; import java.util.Properties; import static org.fest.assertions.Assertions.assertThat; @@ -44,7 +45,7 @@ public class WebappTest { private Env env; @Before - public void initEnv() { + public void initEnv() throws IOException { env = mock(Env.class); File sonarHome = temp.newFolder("home"); when(env.rootDir()).thenReturn(sonarHome); diff --git a/sonar-batch/pom.xml b/sonar-batch/pom.xml index db45a80e535..dbd2cc91a69 100644 --- a/sonar-batch/pom.xml +++ b/sonar-batch/pom.xml @@ -116,18 +116,13 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.codehaus.sonar</groupId> - <artifactId>sonar-testing-harness</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <groupId>org.codehaus.sonar</groupId> + <artifactId>sonar-testing-harness</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java index 55518ac42d2..368dba8268f 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BatchExtensionDictionnaryTest.java @@ -33,7 +33,7 @@ import java.util.Collection; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; +import static org.hamcrest.Matchers.hasItem; import static org.mockito.Mockito.mock; public class BatchExtensionDictionnaryTest { diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java index 3ab8458a7a5..4be6293c27a 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastMeasuresLoaderTest.java @@ -27,10 +27,10 @@ import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.Arrays; import java.util.List; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.nullValue; -import static org.junit.internal.matchers.IsCollectionContaining.hasItems; +import static org.hamcrest.Matchers.hasItems; public class PastMeasuresLoaderTest extends AbstractDbUnitTestCase { diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDateTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDateTest.java index 7423f21a458..7abd043f62b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDateTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDateTest.java @@ -27,7 +27,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class PastSnapshotFinderByDateTest extends AbstractDbUnitTestCase { diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDaysTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDaysTest.java index d9a9809ba07..096a3d6180b 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDaysTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByDaysTest.java @@ -31,7 +31,7 @@ import java.util.Collections; import java.util.Date; import java.util.List; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java index f8ea4da83ba..a2c0d82e301 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/PastSnapshotFinderByPreviousAnalysisTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.sonar.api.database.model.Snapshot; import org.sonar.jpa.test.AbstractDbUnitTestCase; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNull.nullValue; import static org.junit.Assert.assertThat; diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/BucketTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/BucketTest.java index cb20f15cde6..51a9c0269c9 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/BucketTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/BucketTest.java @@ -24,12 +24,12 @@ import org.sonar.api.measures.Metric; import org.sonar.api.resources.Directory; import org.sonar.api.resources.File; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.core.IsNot.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; +import static org.hamcrest.Matchers.hasItem; public class BucketTest { diff --git a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java index c4c7dfd4093..e08774d96c1 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/index/DefaultResourcePersisterTest.java @@ -36,7 +36,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.notNullValue; import static org.mockito.Mockito.mock; diff --git a/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java b/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java index 75897a2abb3..3b1de1e4956 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/maven/DefaultMavenPluginExecutorTest.java @@ -28,7 +28,7 @@ import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import java.io.File; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyList; diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java index 36b396ff437..21e6203d565 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/ModuleFileSystemInitializerTest.java @@ -21,7 +21,7 @@ package org.sonar.batch.scan.filesystem; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; -import org.junit.ClassRule; +import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.sonar.api.batch.bootstrap.ProjectDefinition; @@ -36,8 +36,8 @@ import static org.mockito.Mockito.mock; public class ModuleFileSystemInitializerTest { - @ClassRule - public static TemporaryFolder temp = new TemporaryFolder(); + @Rule + public TemporaryFolder temp = new TemporaryFolder(); PathResolver pathResolver = new PathResolver(); diff --git a/sonar-colorizer/pom.xml b/sonar-colorizer/pom.xml index 9c1a7e277e7..c86f25fa88a 100644 --- a/sonar-colorizer/pom.xml +++ b/sonar-colorizer/pom.xml @@ -31,8 +31,10 @@ <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-all</artifactId> + <version>1.3</version> <scope>test</scope> </dependency> + <dependency> <groupId>org.easytesting</groupId> <artifactId>fest-assert</artifactId> diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml index 7915b7538ec..631bf0b1a95 100644 --- a/sonar-core/pom.xml +++ b/sonar-core/pom.xml @@ -135,7 +135,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> @@ -153,6 +153,19 @@ <artifactId>fest-assert</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>com.google.code.bean-matchers</groupId> + <artifactId>bean-matchers</artifactId> + <version>0.9</version> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-core</artifactId> + </exclusion> + </exclusions> + </dependency> + <!-- JDBC drivers for MyBatis integration tests. diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/BaseDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/BaseDao.java deleted file mode 100644 index 354a954b26c..00000000000 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/BaseDao.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.jpa.dao; - -import org.sonar.api.database.DatabaseSession; - -/** - * @deprecated stop using Hibernate - */ -@Deprecated -public class BaseDao { - - private final DatabaseSession session; - - public BaseDao(DatabaseSession session) { - super(); - this.session = session; - } - - public DatabaseSession getSession() { - return session; - } - -} diff --git a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java index 9ead96effba..acb49f23875 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java +++ b/sonar-core/src/main/java/org/sonar/jpa/dao/MeasuresDao.java @@ -31,12 +31,13 @@ import java.util.Map; import static com.google.common.collect.Lists.newArrayList; -public class MeasuresDao extends BaseDao { +public class MeasuresDao { + private final DatabaseSession session; private final Map<String, Metric> metricsByName = new HashMap<String, Metric>(); public MeasuresDao(DatabaseSession session) { - super(session); + this.session = session; } public Metric getMetric(Metric metric) { @@ -77,8 +78,8 @@ public class MeasuresDao extends BaseDao { } public void disableAutomaticMetrics() { - getSession().createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate(); - getSession().commit(); + session.createQuery("update " + Metric.class.getSimpleName() + " m set m.enabled=false where m.userManaged=false").executeUpdate(); + session.commit(); metricsByName.clear(); } @@ -88,7 +89,7 @@ public class MeasuresDao extends BaseDao { metric.setEnabled(Boolean.TRUE); persistMetricWithoutClear(metric); } - getSession().commit(); + session.commit(); } metricsByName.clear(); } @@ -97,10 +98,10 @@ public class MeasuresDao extends BaseDao { Metric dbMetric = getMetric(metric); if (dbMetric != null) { dbMetric.merge(metric); - getSession().getEntityManager().merge(dbMetric); + session.getEntityManager().merge(dbMetric); } else { - getSession().getEntityManager().persist(new Metric().merge(metric)); + session.getEntityManager().persist(new Metric().merge(metric)); } } @@ -112,14 +113,14 @@ public class MeasuresDao extends BaseDao { public void disabledMetrics(Collection<Metric> metrics) { for (Metric metric : metrics) { metric.setEnabled(Boolean.FALSE); - getSession().getEntityManager().persist(metric); + session.getEntityManager().persist(metric); metricsByName.put(metric.getName(), metric); } } private Map<String, Metric> getMetricsByName() { if (metricsByName.isEmpty()) { - List<Metric> metrics = getSession().getResults(Metric.class); + List<Metric> metrics = session.getResults(Metric.class); for (Metric metric : metrics) { metricsByName.put(metric.getKey(), metric); } diff --git a/sonar-core/src/test/java/org/sonar/core/dashboard/DashboardDaoTest.java b/sonar-core/src/test/java/org/sonar/core/dashboard/DashboardDaoTest.java index 608e812e17e..d7e6fc1f92e 100644 --- a/sonar-core/src/test/java/org/sonar/core/dashboard/DashboardDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/dashboard/DashboardDaoTest.java @@ -25,8 +25,8 @@ import org.sonar.core.persistence.AbstractDaoTestCase; import java.util.Date; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java index 0f299a7bedc..954e9f8c95c 100644 --- a/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java +++ b/sonar-core/src/test/java/org/sonar/core/i18n/GwtI18nTest.java @@ -27,9 +27,9 @@ import org.junit.Test; import java.util.Locale; import java.util.ResourceBundle; -import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.StringContains.containsString; import static org.junit.matchers.JUnitMatchers.hasItems; import static org.mockito.Mockito.mock; diff --git a/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java b/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java index 92ec7651aac..2c589597fb4 100644 --- a/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java +++ b/sonar-core/src/test/java/org/sonar/core/i18n/RuleI18nManagerTest.java @@ -24,7 +24,7 @@ import org.junit.Test; import java.util.Locale; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.*; diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java index bec255186e0..fc918286a03 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeDaoTest.java @@ -33,7 +33,7 @@ import java.util.List; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; -import static org.junit.internal.matchers.IsCollectionContaining.hasItem; +import static org.hamcrest.Matchers.hasItem; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/sonar-core/src/test/java/org/sonar/core/purge/PurgeableSnapshotDtoTest.java b/sonar-core/src/test/java/org/sonar/core/purge/PurgeableSnapshotDtoTest.java index 855386bb16a..58e3c0e3551 100644 --- a/sonar-core/src/test/java/org/sonar/core/purge/PurgeableSnapshotDtoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/purge/PurgeableSnapshotDtoTest.java @@ -22,7 +22,7 @@ package org.sonar.core.purge; import org.junit.Test; import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; public class PurgeableSnapshotDtoTest { diff --git a/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java b/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java index 3744b0d9494..11e1762ef7b 100644 --- a/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java +++ b/sonar-core/src/test/java/org/sonar/core/resource/ResourceIndexerDaoTest.java @@ -29,7 +29,7 @@ import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; -import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertThat; public class ResourceIndexerDaoTest extends AbstractDaoTestCase { diff --git a/sonar-core/src/test/java/org/sonar/core/rule/CacheRuleFinderTest.java b/sonar-core/src/test/java/org/sonar/core/rule/CacheRuleFinderTest.java index a46e8601be1..d2282901d1c 100644 --- a/sonar-core/src/test/java/org/sonar/core/rule/CacheRuleFinderTest.java +++ b/sonar-core/src/test/java/org/sonar/core/rule/CacheRuleFinderTest.java @@ -25,7 +25,7 @@ import org.sonar.api.rules.RuleFinder; import org.sonar.core.rule.CacheRuleFinder; import org.sonar.jpa.test.AbstractDbUnitTestCase; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.notNullValue; import static org.junit.Assert.assertThat; diff --git a/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java b/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java index 99bb844283e..af7ba9655af 100644 --- a/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java +++ b/sonar-core/src/test/java/org/sonar/jpa/session/DatabaseSessionTest.java @@ -20,9 +20,9 @@ package org.sonar.jpa.session; import org.hamcrest.Matchers; +import org.hamcrest.core.IsCollectionContaining; import org.junit.Before; import org.junit.Test; -import org.junit.internal.matchers.IsCollectionContaining; import org.sonar.api.database.model.MeasureModel; import org.sonar.api.database.model.ResourceModel; import org.sonar.api.database.model.Snapshot; diff --git a/sonar-deprecated/pom.xml b/sonar-deprecated/pom.xml index 09672a84961..3559279cd70 100644 --- a/sonar-deprecated/pom.xml +++ b/sonar-deprecated/pom.xml @@ -31,6 +31,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>${project.groupId}</groupId> <artifactId>sonar-plugin-api</artifactId> <type>test-jar</type> @@ -40,7 +45,7 @@ <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-deprecated/src/test/java/org/sonar/api/resources/MethodTest.java b/sonar-deprecated/src/test/java/org/sonar/api/resources/MethodTest.java index b4155c39a72..8d8c7b66f80 100644 --- a/sonar-deprecated/src/test/java/org/sonar/api/resources/MethodTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/resources/MethodTest.java @@ -21,7 +21,7 @@ package org.sonar.api.resources; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class MethodTest { diff --git a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java b/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java index 8573d4c834c..60b63e84de1 100644 --- a/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java +++ b/sonar-deprecated/src/test/java/org/sonar/api/utils/CoberturaReportParserUtilsTest.java @@ -35,7 +35,7 @@ import org.sonar.api.utils.CoberturaReportParserUtils.FileResolver; import java.io.File; import java.net.URISyntaxException; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyDouble; import static org.mockito.Matchers.argThat; diff --git a/sonar-duplications/pom.xml b/sonar-duplications/pom.xml index 966de1cb244..9148f0bad01 100644 --- a/sonar-duplications/pom.xml +++ b/sonar-duplications/pom.xml @@ -65,7 +65,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/block/BlockChunkerTestCase.java b/sonar-duplications/src/test/java/org/sonar/duplications/block/BlockChunkerTestCase.java index 93d8068b088..5b6481b5ef4 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/block/BlockChunkerTestCase.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/block/BlockChunkerTestCase.java @@ -26,7 +26,7 @@ import org.sonar.duplications.statement.Statement; import java.util.Collections; import java.util.List; -import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.*; import static org.junit.Assert.assertThat; /** diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/CloneGroupMatcher.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/CloneGroupMatcher.java index 9d1e5d65e0c..a93fcab72f7 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/CloneGroupMatcher.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/CloneGroupMatcher.java @@ -19,17 +19,17 @@ */ package org.sonar.duplications.detector; +import org.hamcrest.CoreMatchers; import org.hamcrest.Description; import org.hamcrest.Matcher; -import org.hamcrest.Matchers; import org.hamcrest.TypeSafeMatcher; import org.sonar.duplications.index.CloneGroup; import org.sonar.duplications.index.ClonePart; public class CloneGroupMatcher extends TypeSafeMatcher<CloneGroup> { - public static Matcher<Iterable<CloneGroup>> hasCloneGroup(int expectedLen, ClonePart... expectedParts) { - return Matchers.hasItem(new CloneGroupMatcher(expectedLen, expectedParts)); + public static Matcher<Iterable<? super CloneGroup>> hasCloneGroup(int expectedLen, ClonePart... expectedParts) { + return CoreMatchers.hasItem(new CloneGroupMatcher(expectedLen, expectedParts)); } private final int expectedLen; diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java index b44ded89664..100b09d1be8 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java @@ -34,8 +34,8 @@ import java.util.Collections; import java.util.Iterator; import java.util.List; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.sameInstance; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.sameInstance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.junit.matchers.JUnitMatchers.hasItem; diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java index 9831f4531cb..4b63abc419e 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java @@ -22,7 +22,7 @@ package org.sonar.duplications.detector.original; import org.junit.Test; import org.sonar.duplications.block.Block; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class BlocksGroupTest { diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/SuffixTreeTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/SuffixTreeTest.java index 23a5556b2fe..1b961c5e660 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/SuffixTreeTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/detector/suffixtree/SuffixTreeTest.java @@ -19,24 +19,22 @@ */ package org.sonar.duplications.detector.suffixtree; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.lessThan; -import static org.junit.Assert.assertThat; - -import java.util.Arrays; -import java.util.Collection; - import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; +import java.util.Arrays; +import java.util.Collection; + +import static org.fest.assertions.Assertions.assertThat; + @RunWith(Parameterized.class) public class SuffixTreeTest { @Parameters public static Collection<Object[]> generateData() { - return Arrays.asList(new Object[][] { { "banana" }, { "mississippi" }, { "book" }, { "bookke" }, { "cacao" }, { "googol" }, { "abababc" }, { "aaaaa" } }); + return Arrays.asList(new Object[][] { {"banana"}, {"mississippi"}, {"book"}, {"bookke"}, {"cacao"}, {"googol"}, {"abababc"}, {"aaaaa"}}); } private final String data; @@ -50,14 +48,14 @@ public class SuffixTreeTest { String text = this.data + "$"; StringSuffixTree tree = StringSuffixTree.create(text); - assertThat("number of leaves", tree.getNumberOfLeafs(), is(text.length())); - assertThat("number of inner nodes", tree.getNumberOfInnerNodes(), lessThan(text.length() - 1)); - assertThat("number of edges", tree.getNumberOfEdges(), is(tree.getNumberOfInnerNodes() + tree.getNumberOfLeafs())); + assertThat(tree.getNumberOfLeafs()).as("number of leaves").isEqualTo(text.length()); + assertThat(tree.getNumberOfInnerNodes()).as("number of inner nodes").isLessThan(text.length() - 1); + assertThat(tree.getNumberOfEdges()).as("number of edges").isEqualTo(tree.getNumberOfInnerNodes() + tree.getNumberOfLeafs()); for (int beginIndex = 0; beginIndex < text.length(); beginIndex++) { for (int endIndex = beginIndex + 1; endIndex < text.length() + 1; endIndex++) { String substring = text.substring(beginIndex, endIndex); - assertThat("index of " + substring + " in " + text, tree.indexOf(substring), is(text.indexOf(substring))); + assertThat(tree.indexOf(substring)).as("index of " + substring + " in " + text).isEqualTo(text.indexOf(substring)); } } } diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java index 8c11dc4ebae..ea16c856685 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java @@ -29,7 +29,7 @@ import org.junit.Test; import java.io.IOException; import java.util.List; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class TokenizerBridgeTest { diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java index 96818f66752..66fa6dc8294 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java @@ -35,7 +35,7 @@ import org.sonar.duplications.token.TokenChunker; import java.util.Collection; import java.util.List; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; /** diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java index 93ff6fc6c34..3a190a5e3be 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java @@ -23,6 +23,7 @@ import com.google.common.base.Charsets; import com.google.common.collect.Lists; import org.apache.commons.io.IOUtils; import org.hamcrest.Matcher; +import org.hamcrest.Matchers; import org.junit.Test; import org.sonar.duplications.DuplicationsTestUtil; import org.sonar.duplications.token.Token; @@ -37,7 +38,6 @@ import java.io.Reader; import java.util.Arrays; import java.util.List; -import static org.hamcrest.Matchers.greaterThan; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; @@ -303,10 +303,10 @@ public class JavaTokenProducerTest { @Test public void realExamples() { File testFile = DuplicationsTestUtil.findFile("/java/MessageResources.java"); - assertThat(chunk(testFile).size(), greaterThan(0)); + assertThat(chunk(testFile).size(), Matchers.greaterThan(0)); testFile = DuplicationsTestUtil.findFile("/java/RequestUtils.java"); - assertThat(chunk(testFile).size(), greaterThan(0)); + assertThat(chunk(testFile).size(), Matchers.greaterThan(0)); } private TokenQueue chunk(File file) { diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java index 12d89238fc0..c3f6e6450b8 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java @@ -19,7 +19,7 @@ */ package org.sonar.duplications.statement; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; diff --git a/sonar-home/pom.xml b/sonar-home/pom.xml index 1d181ea8e26..5ae4f42a09a 100644 --- a/sonar-home/pom.xml +++ b/sonar-home/pom.xml @@ -39,6 +39,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.easytesting</groupId> <artifactId>fest-assert</artifactId> <scope>test</scope> @@ -51,7 +56,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java index 4de451e884e..ae41e7f88b1 100644 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java +++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaClassTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.sonar.api.resources.Java; import org.sonar.api.resources.Language; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class JavaClassTest { diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java index 36602dd2edd..1af0256a51a 100644 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java +++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaMethodTest.java @@ -21,7 +21,7 @@ package org.sonar.java.api; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class JavaMethodTest { diff --git a/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java b/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java index 09d7b7b4c31..5ec3d97a2a4 100644 --- a/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java +++ b/sonar-java-api/src/test/java/org/sonar/java/api/JavaUtilsTest.java @@ -19,7 +19,7 @@ */ package org.sonar.java.api; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import org.apache.commons.configuration.BaseConfiguration; diff --git a/sonar-markdown/pom.xml b/sonar-markdown/pom.xml index d28e9542fbd..ad0b95d08e7 100644 --- a/sonar-markdown/pom.xml +++ b/sonar-markdown/pom.xml @@ -41,6 +41,11 @@ <artifactId>fest-assert</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> diff --git a/sonar-maven-plugin/pom.xml b/sonar-maven-plugin/pom.xml index a3f47bf7844..b21a1c3e169 100644 --- a/sonar-maven-plugin/pom.xml +++ b/sonar-maven-plugin/pom.xml @@ -42,8 +42,13 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml index 09d12366d3f..0ca8294a407 100644 --- a/sonar-plugin-api/pom.xml +++ b/sonar-plugin-api/pom.xml @@ -157,7 +157,7 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java index 1b613d555ac..ea63a12f5f9 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/bootstrap/ProjectDefinitionTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.batch.bootstrap; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenUtilsTest.java index 32f16e35baa..1eb9b637281 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenUtilsTest.java @@ -27,7 +27,7 @@ import org.sonar.api.test.MavenTestUtils; import java.nio.charset.Charset; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java index 6e279661bd3..7631b6b9b85 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/AesCipherTest.java @@ -34,7 +34,9 @@ import java.security.InvalidKeyException; import java.security.Key; import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.instanceOf; import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.Is.isA; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; @@ -94,7 +96,7 @@ public class AesCipherTest { fail(); } catch (RuntimeException e) { - assertThat(e.getCause(), is(InvalidKeyException.class)); + assertThat(e.getCause(), instanceOf(InvalidKeyException.class)); } } @@ -109,7 +111,7 @@ public class AesCipherTest { fail(); } catch (RuntimeException e) { - assertThat(e.getCause(), is(BadPaddingException.class)); + assertThat(e.getCause(), instanceOf(BadPaddingException.class)); } } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java index 6473578f6ae..265a7cc4f2d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/config/EncryptionTest.java @@ -21,7 +21,7 @@ package org.sonar.api.config; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class EncryptionTest { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java index 0f9a2786c5d..4e15d1ed2fe 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/CountDistributionBuilderTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.measures; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import org.junit.Test; import static org.mockito.Mockito.mock; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeanAggregationFormulaTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeanAggregationFormulaTest.java index 645138e1f00..c1443832c7b 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeanAggregationFormulaTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeanAggregationFormulaTest.java @@ -25,7 +25,7 @@ import org.junit.Test; import java.util.Arrays; import java.util.Collections; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java index 50a565bfd3b..1935e5c19a7 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/MeasureUtilsTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.measures; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java index 5dda2277b0f..1c8ee20eb69 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PersistenceModeTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.measures; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java index 0db658419e2..d540ddb1a61 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/PropertiesBuilderTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.measures; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java index c5eddfc84cc..8d31362cf1d 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java @@ -30,8 +30,8 @@ import java.util.Collections; import java.util.List; import static junit.framework.Assert.assertNull; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DirectoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DirectoryTest.java index bb5bef018f9..0c83e6a8ba9 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/DirectoryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/DirectoryTest.java @@ -25,8 +25,8 @@ import org.junit.rules.TemporaryFolder; import java.io.IOException; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java index 3fe4593e2b0..27a88f14ed4 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/FileTest.java @@ -26,8 +26,8 @@ import org.junit.rules.TemporaryFolder; import java.io.IOException; import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java index 00d2653e6ef..f53b5902b15 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ResourceTypeTreeTest.java @@ -21,7 +21,7 @@ package org.sonar.api.resources; import org.junit.Test; -import static org.hamcrest.collection.IsCollectionContaining.hasItems; +import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.sonar.api.resources.ResourceTypesTest.qualifiers; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java index 136d6c818e2..63b785960bb 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DateUtilsTest.java @@ -28,9 +28,9 @@ import java.util.Date; import java.util.List; import static org.hamcrest.core.Is.is; -import static org.hamcrest.number.OrderingComparisons.greaterThan; -import static org.hamcrest.number.OrderingComparisons.greaterThanOrEqualTo; -import static org.hamcrest.text.StringStartsWith.startsWith; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.*; public class DateUtilsTest { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java index 6031606b2aa..de49842346a 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/DeprecatedKeyValueFormatTest.java @@ -29,7 +29,7 @@ import java.util.Map; import java.util.TreeMap; import static junit.framework.Assert.assertEquals; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; public class DeprecatedKeyValueFormatTest { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/KeyValueFormatTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/KeyValueFormatTest.java index 9e13ef58f24..54a34757d10 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/KeyValueFormatTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/KeyValueFormatTest.java @@ -30,8 +30,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Map; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; public class KeyValueFormatTest { diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java index 601c075baec..e2bcda16ded 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/LocalizedMessagesTest.java @@ -30,7 +30,7 @@ import java.util.List; import java.util.Locale; import java.util.MissingResourceException; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.junit.matchers.JUnitMatchers.hasItems; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java index 36295795f3f..d5f14fa912c 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/ParsingUtilsTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.utils; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java index cdc60323002..6e3001795d8 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/utils/WildcardPatternTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.utils; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java index 54152af7d42..813aa79a4cb 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/web/AbstractRubyTemplateTest.java @@ -19,7 +19,7 @@ */ package org.sonar.api.web; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import org.junit.Test; diff --git a/sonar-server/pom.xml b/sonar-server/pom.xml index 2f57f5d078d..67877dc5a99 100644 --- a/sonar-server/pom.xml +++ b/sonar-server/pom.xml @@ -177,7 +177,12 @@ </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> <scope>test</scope> </dependency> <dependency> @@ -196,11 +201,6 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> - <scope>test</scope> - </dependency> - <dependency> <groupId>xmlunit</groupId> <artifactId>xmlunit</artifactId> <scope>test</scope> diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ClassLoaderUtilsTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ClassLoaderUtilsTest.java index 8d1038d9e9e..6842259d5ad 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/ClassLoaderUtilsTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/ClassLoaderUtilsTest.java @@ -34,6 +34,7 @@ import org.junit.rules.TemporaryFolder; import javax.annotation.Nullable; import java.io.File; +import java.io.IOException; import java.net.URL; import java.net.URLClassLoader; import java.util.Collection; @@ -96,7 +97,7 @@ public class ClassLoaderUtilsTest { } @Test - public void copyRubyRailsApp() { + public void copyRubyRailsApp() throws IOException { File toDir = temp.newFolder("dest"); ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, Functions.<String>identity()); @@ -106,7 +107,7 @@ public class ClassLoaderUtilsTest { } @Test - public void copyRubyRailsApp_relocate_files() { + public void copyRubyRailsApp_relocate_files() throws IOException { File toDir = temp.newFolder("dest"); ClassLoaderUtils.copyResources(classLoader, "org/sonar/sqale", toDir, new Function<String, String>() { public String apply(@Nullable String path) { diff --git a/sonar-server/src/test/java/org/sonar/server/platform/RailsAppsDeployerTest.java b/sonar-server/src/test/java/org/sonar/server/platform/RailsAppsDeployerTest.java index daec51fbd2f..be9c53e4d24 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/RailsAppsDeployerTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/RailsAppsDeployerTest.java @@ -32,7 +32,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.util.Collections; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java index 08bd6360789..4ac7c640fc1 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/ServerIdGeneratorTest.java @@ -28,7 +28,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.text.StringStartsWith.startsWith; +import static org.hamcrest.Matchers.startsWith; import static org.junit.Assert.assertThat; public class ServerIdGeneratorTest { diff --git a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java index b5875e781b6..4bff9fb717f 100644 --- a/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java +++ b/sonar-server/src/test/java/org/sonar/server/ui/ViewProxyTest.java @@ -38,9 +38,9 @@ import java.util.List; import static com.google.common.collect.Iterables.getOnlyElement; import static org.fest.assertions.Assertions.assertThat; -import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.lessThan; -import static org.hamcrest.number.OrderingComparisons.greaterThan; +import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertThat; 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 diff --git a/sonar-ws-client/pom.xml b/sonar-ws-client/pom.xml index 1a1206dd6f0..399fbae3242 100644 --- a/sonar-ws-client/pom.xml +++ b/sonar-ws-client/pom.xml @@ -51,18 +51,18 @@ <scope>test</scope> </dependency> <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-all</artifactId> <scope>test</scope> </dependency> <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-all</artifactId> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> - <artifactId>mockito-all</artifactId> + <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> <dependency> diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java index e35edc16be9..c1ff002fa00 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarTest.java @@ -20,6 +20,7 @@ package org.sonar.wsclient; import org.eclipse.jetty.testing.ServletTester; +import org.hamcrest.Matchers; import org.junit.AfterClass; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,17 +33,11 @@ import org.sonar.wsclient.services.MetricQuery; import org.sonar.wsclient.services.Query; import org.sonar.wsclient.services.Server; import org.sonar.wsclient.services.ServerQuery; -import org.sonar.wsclient.unmarshallers.UnmarshalException; import java.util.Arrays; import java.util.Collection; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.number.OrderingComparisons.greaterThan; import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; -import static org.junit.internal.matchers.StringContains.containsString; @RunWith(value = Parameterized.class) public class SonarTest { @@ -86,20 +81,20 @@ public class SonarTest { @Test public void findAll() { Collection<Metric> metrics = sonar.findAll(MetricQuery.all()); - assertThat(metrics.size(), greaterThan(1)); + assertThat(metrics.size(), Matchers.greaterThan(1)); } @Test public void findEmptyResults() { Query<Metric> query = new EmptyQuery(); Collection<Metric> metrics = sonar.findAll(query); - assertThat(metrics.size(), is(0)); + assertThat(metrics.size(), Matchers.is(0)); } @Test public void returnNullWhenSingleResultNotFound() { Query<Metric> query = new EmptyQuery(); - assertThat(sonar.find(query), nullValue()); + assertThat(sonar.find(query), Matchers.nullValue()); } @Test(expected = ConnectionException.class) @@ -111,8 +106,8 @@ public class SonarTest { @Test public void getVersion() { Server server = sonar.find(new ServerQuery()); - assertThat(server.getId(), is("123456789")); - assertThat(server.getVersion(), is("2.0")); + assertThat(server.getId(), Matchers.is("123456789")); + assertThat(server.getVersion(), Matchers.is("2.0")); } static class EmptyQuery extends Query<Metric> { diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceTest.java index 7ecc3b90a83..ad0a6b0c17e 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ResourceTest.java @@ -21,8 +21,8 @@ package org.sonar.wsclient.services; import org.junit.Test; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; public class ResourceTest { diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java index 4ea3d7eeffa..5f0482b0c06 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshallerTest.java @@ -24,7 +24,7 @@ import org.sonar.wsclient.services.Dependency; import java.util.Collection; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java index 1110782637a..80ea21fd094 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/JsonUtilsTest.java @@ -26,8 +26,8 @@ import org.junit.Test; import java.util.Date; import java.util.TimeZone; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; import static org.junit.Assert.assertThat; public class JsonUtilsTest extends UnmarshallerTestCase { diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java index 5cd345ab8f9..4285e32a9aa 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshallerTest.java @@ -24,7 +24,7 @@ import org.sonar.wsclient.services.ManualMeasure; import java.util.List; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java index 5a183b876c9..a73943a974c 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/MetricUnmarshallerTest.java @@ -24,7 +24,7 @@ import org.sonar.wsclient.services.Metric; import java.util.Collection; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshallerTest.java index 50a306b9a27..2037a5295b4 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshallerTest.java @@ -23,7 +23,7 @@ import org.hamcrest.CoreMatchers; import org.junit.Test; import org.sonar.wsclient.services.Profile; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java index 5de7f5b110d..77d10945c78 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshallerTest.java @@ -24,7 +24,7 @@ import org.sonar.wsclient.services.Property; import java.util.Collection; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshallerTest.java index 7e0c31f478b..fbca555edc8 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshallerTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import org.sonar.wsclient.services.ResourceSearchResult; import org.sonar.wsclient.services.Server; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java index 4fac008d1a0..cc2f1f64faf 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java @@ -24,8 +24,8 @@ import org.sonar.wsclient.services.Resource; import java.util.List; -import static org.hamcrest.CoreMatchers.not; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.not; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java index 149f767e209..a8eeaaea3e2 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java @@ -22,7 +22,7 @@ package org.sonar.wsclient.unmarshallers; import org.junit.Test; import org.sonar.wsclient.services.ServerSetup; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java index 086a615e161..576075e72a1 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerUnmarshallerTest.java @@ -22,7 +22,7 @@ package org.sonar.wsclient.unmarshallers; import org.junit.Test; import org.sonar.wsclient.services.Server; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java index 97c8edeef4e..5acb55f1c8d 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/SourceUnmarshallerTest.java @@ -22,7 +22,7 @@ package org.sonar.wsclient.unmarshallers; import org.junit.Test; import org.sonar.wsclient.services.Source; -import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.Matchers.nullValue; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java index 6cca8815084..8b32b8f2e2c 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/UnmarshallersTest.java @@ -23,15 +23,15 @@ import org.junit.Test; import org.sonar.wsclient.services.Metric; import org.sonar.wsclient.services.Model; -import static org.hamcrest.CoreMatchers.nullValue; -import static org.hamcrest.core.Is.is; +import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.Matchers.instanceOf; import static org.junit.Assert.assertThat; public class UnmarshallersTest { @Test public void forModel() { - assertThat(Unmarshallers.forModel(Metric.class), is(MetricUnmarshaller.class)); + assertThat(Unmarshallers.forModel(Metric.class), instanceOf(MetricUnmarshaller.class)); assertThat(Unmarshallers.forModel(Model.class), nullValue()); } |