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-duplications | |
parent | 24ec2501f751dc2a122f1e5f905ee4151ec8b891 (diff) | |
download | sonarqube-2f779df51e9da5b07ad6f837fe1c98eab9fbf439.tar.gz sonarqube-2f779df51e9da5b07ad6f837fe1c98eab9fbf439.zip |
Upgrade hamcrest and fix conflicts with JUnit and Mockito
Diffstat (limited to 'sonar-duplications')
10 files changed, 24 insertions, 26 deletions
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; |