]> source.dussan.org Git - sonarqube.git/commitdiff
Continue move from hamcrest to fest-assert
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 21 Apr 2014 21:41:03 +0000 (23:41 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 21 Apr 2014 21:41:03 +0000 (23:41 +0200)
38 files changed:
plugins/sonar-l10n-en-plugin/pom.xml
sonar-application/pom.xml
sonar-batch-maven-compat/pom.xml
sonar-batch/pom.xml
sonar-batch/src/test/java/org/sonar/batch/phases/DecoratorsExecutorTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java
sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java
sonar-deprecated/pom.xml
sonar-deprecated/src/test/java/org/sonar/api/resources/MethodTest.java
sonar-deprecated/src/test/java/org/sonar/api/rules/RuleUtilsTest.java
sonar-duplications/src/test/java/org/sonar/duplications/DuplicationPredicatesTest.java
sonar-duplications/src/test/java/org/sonar/duplications/block/BlockChunkerTestCase.java
sonar-duplications/src/test/java/org/sonar/duplications/detector/DetectorTestCase.java
sonar-duplications/src/test/java/org/sonar/duplications/detector/original/BlocksGroupTest.java
sonar-duplications/src/test/java/org/sonar/duplications/internal/pmd/TokenizerBridgeTest.java
sonar-duplications/src/test/java/org/sonar/duplications/java/JavaDuplicationsFunctionalTest.java
sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java
sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java
sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java
sonar-duplications/src/test/java/org/sonar/duplications/token/BlackHoleTokenChannelTest.java
sonar-plugin-api/src/test/java/org/sonar/api/database/model/UserTest.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/ManifestUtilsTest.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/ValidationMessagesTest.java
sonar-plugin-api/src/test/java/org/sonar/api/utils/command/CommandExecutorTest.java
sonar-server/pom.xml
sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerSetupQueryTest.java
sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshallerTest.java

index 58dfa5def1302ff38e370e21e72d96664cc94a4c..4018b3a905eb389265154265e7e9d268eb3f5ee2 100644 (file)
@@ -25,7 +25,7 @@
   <parent>
     <groupId>org.codehaus.sonar</groupId>
     <artifactId>sonar</artifactId>
-    <version>4.3-SNAPSHOT</version>
+    <version>4.4-SNAPSHOT</version>
     <relativePath>../..</relativePath>
   </parent>
 
 
   <build>
     <plugins>
-      <plugin>
-        <groupId>org.codehaus.mojo</groupId>
-        <artifactId>native2ascii-maven-plugin</artifactId>
-        <version>1.0-beta-1</version>
-        <executions>
-          <execution>
-            <goals>
-              <goal>native2ascii</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <groupId>org.codehaus.sonar</groupId>
         <artifactId>sonar-packaging-maven-plugin</artifactId>
index 4c70ca1d0d477ed71b9e715573184802738de085..60c410f9536b5864187f54d94e45f9aa870cb99a 100644 (file)
@@ -58,9 +58,9 @@
       <artifactId>logback-core</artifactId>
     </dependency>
     <dependency>
-      <groupId>${pom.groupId}</groupId>
+      <groupId>${project.groupId}</groupId>
       <artifactId>sonar-batch-maven-compat</artifactId>
-      <version>${pom.version}</version>
+      <version>${project.version}</version>
       <scope>runtime</scope>
     </dependency>
     <dependency>
index a19f029a522470ee5b73713a2729ebcd514ffcb9..b8a02ee6920fd92de996b238c4dfd419f9074dd0 100644 (file)
@@ -14,9 +14,9 @@
 
   <dependencies>
     <dependency>
-      <groupId>${pom.groupId}</groupId>
+      <groupId>${project.groupId}</groupId>
       <artifactId>sonar-batch</artifactId>
-      <version>${pom.version}</version>
+      <version>${project.version}</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
index 3d268b2f939e5bdd3a49435b06a4be86c5e69ac6..8e527478c01118590111de4d3a946b608d67544c 100644 (file)
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-all</artifactId>
+      <groupId>org.easytesting</groupId>
+      <artifactId>fest-assert</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
       <artifactId>sonar-testing-harness</artifactId>
       <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>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>org.eclipse.jetty</groupId>
       <artifactId>jetty-server</artifactId>
index a1118d316d74c791864ece1cf2ee694eba7c6de3..3534236e5036cfb7ab83ec962e66261d625250db 100644 (file)
@@ -32,11 +32,8 @@ import org.sonar.batch.DefaultDecoratorContext;
 import org.sonar.batch.events.EventBus;
 import org.sonar.core.measure.MeasurementFilters;
 
-import static org.hamcrest.number.OrderingComparisons.greaterThanOrEqualTo;
-import static org.hamcrest.number.OrderingComparisons.lessThan;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.mock;
@@ -54,11 +51,11 @@ public class DecoratorsExecutorTest {
     profiler.start(decorator2);
     profiler.stop();
 
-    assertThat(profiler.getMessage().indexOf("Decorator1"), greaterThanOrEqualTo(0));
-    assertThat(profiler.getMessage().indexOf("Decorator2"), greaterThanOrEqualTo(0));
+    assertThat(profiler.getMessage().indexOf("Decorator1")).isGreaterThanOrEqualTo(0);
+    assertThat(profiler.getMessage().indexOf("Decorator2")).isGreaterThanOrEqualTo(0);
 
     // sequence of execution
-    assertThat(profiler.getMessage().indexOf("Decorator1"), lessThan(profiler.getMessage().indexOf("Decorator2")));
+    assertThat(profiler.getMessage().indexOf("Decorator1")).isLessThan(profiler.getMessage().indexOf("Decorator2"));
   }
 
   @Test
@@ -73,7 +70,7 @@ public class DecoratorsExecutorTest {
       fail("Exception has not been thrown");
 
     } catch (SonarException e) {
-      assertThat(e.getMessage(), containsString("src/org/foo/Bar.java"));
+      assertThat(e.getMessage()).contains("src/org/foo/Bar.java");
     }
   }
 
index a2436da7b7216ac652cd2256490c256fd47549c0..7e2616ea2099685400bb0ec97c9f53b718db2a1b 100644 (file)
@@ -23,10 +23,7 @@ import org.junit.Before;
 import org.junit.Test;
 import org.sonar.channel.CodeReader;
 
-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 org.fest.assertions.Assertions.assertThat;
 
 public class CDocTokenizerTest {
 
@@ -40,10 +37,10 @@ public class CDocTokenizerTest {
   @Test
   public void testRead() {
     CDocTokenizer tokenizer = new CDocTokenizer("<c>", "</c>");
-    assertTrue(tokenizer.consume(new CodeReader("//this is a comment"), codeBuilder));
-    assertThat(codeBuilder.toString(), is("<c>//this is a comment</c>"));
+    assertThat(tokenizer.consume(new CodeReader("//this is a comment"), codeBuilder)).isTrue();
+    assertThat(codeBuilder.toString()).isEqualTo("<c>//this is a comment</c>");
 
-    assertFalse(tokenizer.consume(new CodeReader("this is not a comment"), codeBuilder));
-    assertThat(codeBuilder.toString(), is("<c>//this is a comment</c>"));
+    assertThat(tokenizer.consume(new CodeReader("this is not a comment"), codeBuilder)).isFalse();
+    assertThat(codeBuilder.toString()).isEqualTo("<c>//this is a comment</c>");
   }
 }
index 889241b0d0643478e713ba5117a8c98c4636e717..ffb379c0637303787ca44afdda9959744390b4ec 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
 import org.junit.Test;
 
+import static org.fest.assertions.Assertions.assertThat;
+import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
+
 public class CaseInsensitiveKeywordsTokenizerTest {
 
   @Test
   public void hasNextToken() {
     CaseInsensitiveKeywordsTokenizer tokenizer = new CaseInsensitiveKeywordsTokenizer("<k>", "</k>", "PROCEDURE");
-    assertThat(highlight("procedure name", tokenizer), is("<k>procedure</k> name"));
-    assertThat(highlight("Procedure name", tokenizer), is("<k>Procedure</k> name"));
-    assertThat(highlight("PROCEDURE name", tokenizer), is("<k>PROCEDURE</k> name"));
+    assertThat(highlight("procedure name", tokenizer)).isEqualTo("<k>procedure</k> name");
+    assertThat(highlight("Procedure name", tokenizer)).isEqualTo("<k>Procedure</k> name");
+    assertThat(highlight("PROCEDURE name", tokenizer)).isEqualTo("<k>PROCEDURE</k> name");
   }
 
   @Test
   public void testClone() {
     CaseInsensitiveKeywordsTokenizer tokenizer = new CaseInsensitiveKeywordsTokenizer("<k>", "</k>", "PROCEDURE");
     Tokenizer cloneTokenizer = tokenizer.clone();
-    assertThat(tokenizer, is(not(cloneTokenizer)));
-    assertThat(highlight("procedure name", cloneTokenizer), is("<k>procedure</k> name"));
+    assertThat(tokenizer).isNotEqualTo(cloneTokenizer);
+    assertThat(highlight("procedure name", cloneTokenizer)).isEqualTo("<k>procedure</k> name");
   }
 }
index 3c5860d3c829acf5a218fba24b2165cd08ce8458..b60d3d1b68328fe97bfee2e6c5eb01b8fd579221 100644 (file)
@@ -33,12 +33,7 @@ import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class CodeColorizerTest {
 
@@ -69,8 +64,8 @@ public class CodeColorizerTest {
     HtmlOptions options = new HtmlOptions(true, "my-table-id", false);
     String html = CodeColorizer.javaToHtml(java, options);
 
-    assertThat(html, containsString("<table class=\"code\" id=\"my-table-id\""));
-    assertThat(html, not(containsString("<style")));
+    assertThat(html).contains("<table class=\"code\" id=\"my-table-id\"");
+    assertThat(html).doesNotContain("<style");
   }
 
   @Test
@@ -85,8 +80,8 @@ public class CodeColorizerTest {
 
   @Test
   public void getCss() {
-    assertThat(CodeColorizer.getCss().length(), greaterThan(100));
-    assertThat(CodeColorizer.getCss(), containsString(".code"));
+    assertThat(CodeColorizer.getCss().length()).isGreaterThan(100);
+    assertThat(CodeColorizer.getCss()).contains(".code");
   }
 
   @Test
@@ -113,12 +108,12 @@ public class CodeColorizerTest {
     }
     List<Future<String>> futures = Executors.newFixedThreadPool(threadCount).invokeAll(tasks);
 
-    assertThat(futures.size(), is(taskCount));
+    assertThat(futures).hasSize(taskCount);
 
     // all html must be the same
     String html = futures.get(0).get();
     for (Future<String> future : futures) {
-      assertEquals(html, future.get());
+      assertThat(html).isEqualTo(future.get());
     }
   }
 
@@ -131,10 +126,10 @@ public class CodeColorizerTest {
 
     assertHtml(html);
     assertContains(html, "<pre>  <span class=\"cppd\">/*</span></pre>",
-                         "<pre><span class=\"cppd\">   * This method does &lt;b&gt;something&lt;/b&gt;</span></pre>",
-                         "<pre><span class=\"cppd\">   *</span></pre>",
-                         "<pre><span class=\"cppd\">   * &amp;lt;p&amp;gt;description&amp;lt;/p&amp;gt;</span></pre>",
-                         "<pre><span class=\"cppd\">   */</span></pre>");
+      "<pre><span class=\"cppd\">   * This method does &lt;b&gt;something&lt;/b&gt;</span></pre>",
+      "<pre><span class=\"cppd\">   *</span></pre>",
+      "<pre><span class=\"cppd\">   * &amp;lt;p&amp;gt;description&amp;lt;/p&amp;gt;</span></pre>",
+      "<pre><span class=\"cppd\">   */</span></pre>");
   }
 
   /**
@@ -161,7 +156,7 @@ public class CodeColorizerTest {
 
   private void assertContains(String html, String... strings) {
     for (String string : strings) {
-      assertThat(html, containsString(string));
+      assertThat(html).contains(string);
     }
   }
 }
index 42ec296b0db759a01ebbeef832f825117b6d9031..60b5880e0ee31d1c94ecbbf76c2ffc7a9d3a0214 100644 (file)
@@ -22,10 +22,7 @@ package org.sonar.colorizer;
 import org.junit.Before;
 import org.junit.Test;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.core.IsNull.nullValue;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class HtmlCodeBuilderTest {
 
@@ -39,7 +36,7 @@ public class HtmlCodeBuilderTest {
   @Test
   public void testAppendCharSequence() {
     builder.append("freddy < olivier");
-    assertEquals("freddy &lt; olivier", builder.toString());
+    assertThat("freddy &lt; olivier").isEqualTo(builder.toString());
   }
 
   @Test
@@ -47,35 +44,35 @@ public class HtmlCodeBuilderTest {
     builder.append('p');
     builder.append('a');
     builder.append('>');
-    assertEquals("pa&gt;", builder.toString());
+    assertThat("pa&gt;").isEqualTo(builder.toString());
   }
 
   @Test
   public void testAppendCharSequenceIntInt() {
     builder.append("freddy < olivier", 0, 2);
-    assertEquals("fr", builder.toString());
+    assertThat("fr").isEqualTo(builder.toString());
   }
 
   @Test
   public void testAppendWithoutTransforming() {
     builder.appendWithoutTransforming("<inside>outside");
-    assertEquals("<inside>outside", builder.toString());
+    assertThat("<inside>outside").isEqualTo(builder.toString());
   }
 
   @Test
   public void testStatefulVariables() {
-    assertThat(builder.getVariable("foo"), nullValue());
+    assertThat(builder.getVariable("foo")).isNull();
 
     builder.setVariable("foo", "xxx");
-    assertThat((String) builder.getVariable("foo"), is("xxx"));
+    assertThat((String) builder.getVariable("foo")).isEqualTo(("xxx"));
 
     builder.setVariable("foo", "yyy");
-    assertThat((String) builder.getVariable("foo"), is("yyy"));
+    assertThat((String) builder.getVariable("foo")).isEqualTo(("yyy"));
 
     builder.setVariable("foo", null);
-    assertThat(builder.getVariable("foo"), nullValue());
+    assertThat(builder.getVariable("foo")).isNull();
 
-    assertThat((String) builder.getVariable("foo", "default"), is("default"));
+    assertThat((String) builder.getVariable("foo", "default")).isEqualTo(("default"));
   }
 
 }
index eea8b1b580a12c6edb41824b046a1b51c24d0c76..00919dfcd7cdfcbbea3427356393c523748e9c5f 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.core.IsNot.not;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
-import static org.junit.internal.matchers.StringContains.containsString;
-
 import org.junit.Test;
 import org.sonar.channel.CodeReader;
 
+import static org.fest.assertions.Assertions.assertThat;
+
 public class HtmlDecoratorTest {
 
   @Test
@@ -84,34 +80,35 @@ public class HtmlDecoratorTest {
     HtmlCodeBuilder output = new HtmlCodeBuilder();
 
     output.appendWithoutTransforming(decorator.getTagBeginOfFile());
-    assertThat(decorator.consume(code, output), is(true));
-    assertThat(decorator.consume(code, output), is(true));
-    assertThat(decorator.consume(code, output), is(true));
+    assertThat(decorator.consume(code, output)).isTrue();
+    assertThat(decorator.consume(code, output)).isTrue();
+    assertThat(decorator.consume(code, output)).isTrue();
     output.appendWithoutTransforming(decorator.getTagEndOfFile());
-    
-    assertThat(output.toString(), is(
-        "<table class=\"code\" id=\"\"><tbody>"
-        + "<tr id=\"1\"><td><pre></pre></td></tr>" 
-        + "<tr id=\"2\"><td><pre></pre></td></tr>" 
+
+    assertThat(output.toString()).isEqualTo(
+      "<table class=\"code\" id=\"\"><tbody>"
+        + "<tr id=\"1\"><td><pre></pre></td></tr>"
+        + "<tr id=\"2\"><td><pre></pre></td></tr>"
         + "<tr id=\"3\"><td><pre></pre></td></tr>"
-        + "</tbody></table>"));
+        + "</tbody></table>"
+    );
   }
 
   @Test
   public void getCss() {
-    assertThat(HtmlDecorator.getCss().length(), greaterThan(100));
-    assertThat(HtmlDecorator.getCss(), containsString(".code"));
+    assertThat(HtmlDecorator.getCss().length()).isGreaterThan(100);
+    assertThat(HtmlDecorator.getCss()).contains(".code");
   }
 
   public void assertContains(String html, String... strings) {
     for (String string : strings) {
-      assertThat(html, containsString(string));
+      assertThat(html).contains(string);
     }
   }
 
   public void assertNotContains(String html, String... strings) {
     for (String string : strings) {
-      assertThat(html, not(containsString(string)));
+      assertThat(html).doesNotContain(string);
     }
   }
 }
index 74d9bc6947696ffdc9655f1b18a6d8253e20fe85..b317640237797e80c8a82415f4b6a6238bc90149 100644 (file)
@@ -28,9 +28,7 @@ import java.io.IOException;
 import java.io.StringReader;
 import java.util.Arrays;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.internal.matchers.StringContains.containsString;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class HtmlRendererTest {
 
@@ -42,7 +40,7 @@ public class HtmlRendererTest {
 
     String html = htmlRenderer.render(new StringReader("public class Hello {"), Arrays.asList(javaKeywordTokenizer));
 
-    assertThat(html, is("<span class='k'>public</span> <span class='k'>class</span> Hello {"));
+    assertThat(html).isEqualTo("<span class='k'>public</span> <span class='k'>class</span> Hello {");
   }
 
   @Test
@@ -51,7 +49,7 @@ public class HtmlRendererTest {
 
     String html = htmlRenderer.render(new StringReader("foo(\"<html>\");"), Arrays.asList(new LiteralTokenizer("<s>", "</s>")));
 
-    assertThat(html, is("foo(<s>\"&lt;html&gt;\"</s>);"));
+    assertThat(html).isEqualTo("foo(<s>\"&lt;html&gt;\"</s>);");
   }
 
   @Test
@@ -60,13 +58,13 @@ public class HtmlRendererTest {
 
     String html = new HtmlRenderer().render(new FileReader(java), Arrays.asList(javaKeywordTokenizer));
 
-    assertThat(html, containsString("<html>"));
-    assertThat(html, containsString("<style"));
-    assertThat(html, containsString("<table class=\"code\""));
-    assertThat(html, containsString("public"));
-    assertThat(html, containsString("class"));
-    assertThat(html, containsString("Sample"));
-    assertThat(html, containsString("</html>"));
+    assertThat(html).contains("<html>");
+    assertThat(html).contains("<style");
+    assertThat(html).contains("<table class=\"code\"");
+    assertThat(html).contains("public");
+    assertThat(html).contains("class");
+    assertThat(html).contains("Sample");
+    assertThat(html).contains("</html>");
   }
 
 }
index 26ad9eb3ed4866d07c63d7865c6f5fcac303dba6..0e6ced248603ab5e2fb2a54a03bf2c086e825b0b 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
 import org.junit.Test;
 
+import static org.fest.assertions.Assertions.assertThat;
+import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
+
 public class JavaAnnotationTokenizerTest {
 
   JavaAnnotationTokenizer tokenizer = new JavaAnnotationTokenizer("<a>", "</a>");
 
   @Test
   public void testHighlighting() {
-    assertThat(highlight("@deprecated public", tokenizer), is("<a>@deprecated</a> public"));
-    assertThat(highlight("import", tokenizer), is("import"));
+    assertThat(highlight("@deprecated public", tokenizer)).isEqualTo("<a>@deprecated</a> public");
+    assertThat(highlight("import", tokenizer)).isEqualTo("import");
   }
 
   @Test
   public void testHighlightingWithProperties() {
-    assertThat(highlight("@Target(ElementType.METHOD)", tokenizer), is("<a>@Target</a>(ElementType.METHOD)"));
+    assertThat(highlight("@Target(ElementType.METHOD)", tokenizer)).isEqualTo("<a>@Target</a>(ElementType.METHOD)");
   }
 }
index dbab1f20a06ce5dd266eada6bf87e526fbe0216a..90fd7a22731e8e203811919323c9790933f48695 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
 import org.junit.Test;
-import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
+
+import static org.fest.assertions.Assertions.assertThat;
 
 public class JavaKeywordsTest {
 
   @Test
   public void get() {
-    assertThat(JavaKeywords.get().size(), is(53));
-    assertThat(JavaKeywords.get(), hasItem("true"));
-    assertThat(JavaKeywords.get(), hasItem("public"));
-    assertThat(JavaKeywords.get(), hasItem("switch"));
+    assertThat(JavaKeywords.get()).hasSize(53);
+    assertThat(JavaKeywords.get()).contains("true", "public", "switch");
   }
 }
index 98e9706186dda5c9da43ed6ebc8f13ddb0dbb86a..01527269a29d50bc17399c9a73879ba5bb0994f4 100644 (file)
@@ -23,24 +23,21 @@ import java.util.List;
 
 import org.junit.Test;
 
-import static junit.framework.Assert.fail;
-
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.hamcrest.number.OrderingComparisons.lessThan;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
+import static org.junit.Assert.fail;
 
 public class JavaTokenizersTest {
 
   @Test
   public void forHtml() {
-    assertThat(JavaTokenizers.forHtml().size(), greaterThan(3));
+    assertThat(JavaTokenizers.forHtml().size()).isGreaterThan(3);
   }
 
   @Test
   public void javadocIsDefinedBeforeCppComment() {
     // just because /** must be detected before /*
-    assertThat(indexOf(JavaTokenizers.forHtml(), JavadocTokenizer.class),
-        lessThan(indexOf(JavaTokenizers.forHtml(), CppDocTokenizer.class)));
+    assertThat(indexOf(JavaTokenizers.forHtml(), JavadocTokenizer.class)).isLessThan(
+      indexOf(JavaTokenizers.forHtml(), CppDocTokenizer.class));
   }
 
   private Integer indexOf(List<Tokenizer> tokenizers, Class tokenizerClass) {
index 0474a6ceff59796e513ba2fcd5cb05798266b7fb..809c27794fff2da6ff7493ba951a194dad241624 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
 import org.junit.Test;
 
+import static org.fest.assertions.Assertions.assertThat;
+import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
+
 public class JavadocTokenizerTest {
 
   JavadocTokenizer tokenizer = new JavadocTokenizer("<j>", "</j>");
 
   @Test
   public void testHighlighting() {
-    assertThat(highlight("/**this is a javadoc*/ public ...", tokenizer), is("<j>/**this is a javadoc*/</j> public ..."));
-    assertThat(highlight("//this is not a javadoc", tokenizer), is("//this is not a javadoc"));
+    assertThat(highlight("/**this is a javadoc*/ public ...", tokenizer)).isEqualTo("<j>/**this is a javadoc*/</j> public ...");
+    assertThat(highlight("//this is not a javadoc", tokenizer)).isEqualTo("//this is not a javadoc");
   }
 
   @Test
   public void testHighlightingOnMultipleLines() {
-    assertThat(highlight("/**this is \n a javadoc*/ private", tokenizer), is("<j>/**this is </j>\n<j> a javadoc*/</j> private"));
+    assertThat(highlight("/**this is \n a javadoc*/ private", tokenizer)).isEqualTo("<j>/**this is </j>\n<j> a javadoc*/</j> private");
   }
 }
index 086196a6c4a9374f065c01258c5ffd62ff512e39..e36736db923efb17966450c07bcacf31b7118ff3 100644 (file)
@@ -19,9 +19,7 @@
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
 
 import org.junit.Test;
@@ -31,28 +29,28 @@ public class KeywordsTokenizerTest {
   @Test
   public void testColorizeKeywords() {
     KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "public", "new");
-    assertThat(highlight("new()", tokenizer), is("<s>new</s>()"));
-    assertThat(highlight("public new get()", tokenizer), is("<s>public</s> <s>new</s> get()"));
-    assertThat(highlight("publication", tokenizer), is("publication"));
+    assertThat(highlight("new()", tokenizer)).isEqualTo("<s>new</s>()");
+    assertThat(highlight("public new get()", tokenizer)).isEqualTo("<s>public</s> <s>new</s> get()");
+    assertThat(highlight("publication", tokenizer)).isEqualTo("publication");
   }
 
   @Test
   public void testUnderscoreAndDigit() {
     KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "_01public");
-    assertThat(highlight("_01public", tokenizer), is("<s>_01public</s>"));
+    assertThat(highlight("_01public", tokenizer)).isEqualTo("<s>_01public</s>");
   }
 
   @Test
   public void testCaseSensitive() {
     KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "public");
-    assertThat(highlight("PUBLIC Public public", tokenizer), is("PUBLIC Public <s>public</s>"));
+    assertThat(highlight("PUBLIC Public public", tokenizer)).isEqualTo("PUBLIC Public <s>public</s>");
   }
   
   @Test
   public void testClone() {
     KeywordsTokenizer tokenizer = new KeywordsTokenizer("<s>", "</s>", "public", "[a-z]+");
     KeywordsTokenizer cloneTokenizer = tokenizer.clone();
-    assertThat(tokenizer, is(not(cloneTokenizer)));
-    assertThat(highlight("public 1234", cloneTokenizer), is("<s>public</s> 1234"));
+    assertThat(tokenizer).isNotEqualTo(cloneTokenizer);
+    assertThat(highlight("public 1234", cloneTokenizer)).isEqualTo("<s>public</s> 1234");
   }
 }
index c1d0ba47a5a21d12579377644335312eed497ec7..86475b2587d91a0bb2e2a7dc938f3a27b2ae545d 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertThat;
-import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
-
 import org.junit.Test;
 
+import static org.fest.assertions.Assertions.assertThat;
+import static org.sonar.colorizer.SyntaxHighlighterTestingHarness.highlight;
+
 public class RegexpTokenizerTest {
 
-  RegexpTokenizer tokenHighlighter;;
+  RegexpTokenizer tokenHighlighter;
+  ;
 
   @Test
   public void testHighlight() {
     tokenHighlighter = new RegexpTokenizer("<r>", "</r>", "[0-9]+");
-    assertThat(highlight("123, word = 435;", tokenHighlighter), is("<r>123</r>, word = <r>435</r>;"));
+    assertThat(highlight("123, word = 435;", tokenHighlighter)).isEqualTo("<r>123</r>, word = <r>435</r>;");
   }
-  
+
   @Test
   public void testClone() {
     RegexpTokenizer tokenizer = new RegexpTokenizer("<r>", "</r>", "[a-z]+");
     RegexpTokenizer cloneTokenizer = tokenizer.clone();
-    assertThat(tokenizer, is(not(cloneTokenizer)));
-    assertThat(highlight("public 1234", cloneTokenizer), is("<r>public</r> 1234"));
+    assertThat(tokenizer).isNotEqualTo(cloneTokenizer);
+    assertThat(highlight("public 1234", cloneTokenizer)).isEqualTo("<r>public</r> 1234");
   }
 
 }
index e933ea36443980dd5b521c9f6f0391a3e662e506..075488064392f96c0e0abff6e98d36beaada3df4 100644 (file)
  */
 package org.sonar.colorizer;
 
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
-import java.util.Arrays;
-
 import org.junit.Test;
 import org.sonar.channel.Channel;
 import org.sonar.channel.CodeReader;
 
+import java.util.Arrays;
+
+import static org.fest.assertions.Assertions.assertThat;
+
 public class TokenizerDispatcherTest {
 
   @Test
   public void testPipeCodeTokenizer() {
     TokenizerDispatcher colorization = newColorizer();
-    assertThat(colorization.colorize("public void get(){"), is("public void get(){"));
+    assertThat(colorization.colorize("public void get(){")).isEqualTo("public void get(){");
   }
 
   @Test
   public void testKeywordsCodeTokenizer() {
     TokenizerDispatcher colorization = newColorizer(new KeywordsTokenizer("<k>", "</k>", JavaKeywords.get()));
-    assertThat(colorization.colorize("public void get(){"), is("<k>public</k> <k>void</k> get(){"));
+    assertThat(colorization.colorize("public void get(){")).isEqualTo("<k>public</k> <k>void</k> get(){");
   }
 
   @Test
   public void testPriorityToComment() {
     TokenizerDispatcher colorization = newColorizer(new CDocTokenizer("<c>", "</c>"), new KeywordsTokenizer("<k>", "</k>", JavaKeywords
-        .get()));
-    assertThat(colorization.colorize("assert //public void get(){"), is("<k>assert</k> <c>//public void get(){</c>"));
+      .get()));
+    assertThat(colorization.colorize("assert //public void get(){")).isEqualTo("<k>assert</k> <c>//public void get(){</c>");
   }
 
   @Test
   public void testCommentThenStringThenJavaKeywords() {
     TokenizerDispatcher colorization = newColorizer(new CDocTokenizer("<c>", "</c>"), new LiteralTokenizer("<s>", "</s>"),
-        new KeywordsTokenizer("<k>", "</k>", JavaKeywords.get()));
-    assertThat(colorization.colorize("assert(\"message\"); //comment"), is("<k>assert</k>(<s>\"message\"</s>); <c>//comment</c>"));
+      new KeywordsTokenizer("<k>", "</k>", JavaKeywords.get()));
+    assertThat(colorization.colorize("assert(\"message\"); //comment")).isEqualTo("<k>assert</k>(<s>\"message\"</s>); <c>//comment</c>");
   }
 
   @Test(expected = IllegalStateException.class)
index 6d00457ee5aa6e42117263522934dc3fa78a51db..09672a84961bb6df43b343c0e1c6ea1645e4d1fe 100644 (file)
       <scope>test</scope>
     </dependency>
 
-    <dependency>
-      <groupId>${project.groupId}</groupId>
-      <artifactId>sonar-testing-harness</artifactId>
-      <version>${project.version}</version>
-      <scope>test</scope>
-    </dependency>
     <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
index 8d8c7b66f80d94f6465f0e0b285008fbc7838db9..b4155c39a72745e7036e312d93d1d7e70c4eaa3b 100644 (file)
@@ -21,7 +21,7 @@ package org.sonar.api.resources;
 
 import org.junit.Test;
 
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
 public class MethodTest {
index a58e3d4bdc1628152671fd801825646be14a4504..643f673f89c10c5fffce64c1d6d4df74e6cc110f 100644 (file)
@@ -26,8 +26,7 @@ import org.sonar.api.CoreProperties;
 
 import java.util.Map;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
@@ -41,11 +40,11 @@ public class RuleUtilsTest {
 
     final Map<RulePriority, Integer> map = RuleUtils.getPriorityWeights(conf);
 
-    assertThat(map.get(RulePriority.BLOCKER), is(10));
-    assertThat(map.get(RulePriority.CRITICAL), is(5));
-    assertThat(map.get(RulePriority.MAJOR), is(2));
-    assertThat(map.get(RulePriority.MINOR), is(1));
-    assertThat(map.get(RulePriority.INFO), is(0));
+    assertThat(map.get(RulePriority.BLOCKER)).isEqualTo(10);
+    assertThat(map.get(RulePriority.CRITICAL)).isEqualTo(5);
+    assertThat(map.get(RulePriority.MAJOR)).isEqualTo(2);
+    assertThat(map.get(RulePriority.MINOR)).isEqualTo(1);
+    assertThat(map.get(RulePriority.INFO)).isEqualTo(0);
   }
 
   @Test
@@ -55,11 +54,11 @@ public class RuleUtilsTest {
 
     final Map<RulePriority, Integer> map = RuleUtils.getPriorityWeights(conf);
 
-    assertThat(map.get(RulePriority.BLOCKER), is(1));
-    assertThat(map.get(RulePriority.CRITICAL), is(5));
-    assertThat(map.get(RulePriority.MAJOR), is(1));
-    assertThat(map.get(RulePriority.MINOR), is(1));
-    assertThat(map.get(RulePriority.INFO), is(1));
+    assertThat(map.get(RulePriority.BLOCKER)).isEqualTo(1);
+    assertThat(map.get(RulePriority.CRITICAL)).isEqualTo(5);
+    assertThat(map.get(RulePriority.MAJOR)).isEqualTo(1);
+    assertThat(map.get(RulePriority.MINOR)).isEqualTo(1);
+    assertThat(map.get(RulePriority.INFO)).isEqualTo(1);
   }
 
 }
index 6262929bbb29711d4f40b39a08e831d7a7abca6d..146106b3442f0ce228950bb138713a0336eb5b1a 100644 (file)
@@ -23,17 +23,16 @@ import com.google.common.base.Predicate;
 import org.junit.Test;
 import org.sonar.duplications.index.CloneGroup;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class DuplicationPredicatesTest {
 
   @Test
   public void testNumberOfUnitsNotLessThan() {
     Predicate<CloneGroup> predicate = DuplicationPredicates.numberOfUnitsNotLessThan(5);
-    assertThat(predicate.apply(CloneGroup.builder().setLengthInUnits(6).build()), is(true));
-    assertThat(predicate.apply(CloneGroup.builder().setLengthInUnits(5).build()), is(true));
-    assertThat(predicate.apply(CloneGroup.builder().setLengthInUnits(4).build()), is(false));
+    assertThat(predicate.apply(CloneGroup.builder().setLengthInUnits(6).build())).isTrue();
+    assertThat(predicate.apply(CloneGroup.builder().setLengthInUnits(5).build())).isTrue();
+    assertThat(predicate.apply(CloneGroup.builder().setLengthInUnits(4).build())).isFalse();
   }
 
 }
index 5b6481b5ef450e847b90b45da51f4d40eadbc4f6..93d8068b08850b54aabf3b7da09d2eb05e7de84e 100644 (file)
@@ -26,7 +26,7 @@ import org.sonar.duplications.statement.Statement;
 import java.util.Collections;
 import java.util.List;
 
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.CoreMatchers.*;
 import static org.junit.Assert.assertThat;
 
 /**
index 6a26def7e81a7bb5a955bec433c6dfb322c80eed..b44ded896643e7611624e5de47f5c5fac3c6d66b 100644 (file)
@@ -30,12 +30,18 @@ import org.sonar.duplications.index.ClonePart;
 import org.sonar.duplications.index.MemoryCloneIndex;
 import org.sonar.duplications.junit.TestNamePrinter;
 
-import java.util.*;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
-import static org.hamcrest.Matchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.sameInstance;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
+import static org.junit.matchers.JUnitMatchers.hasItem;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
 import static org.sonar.duplications.detector.CloneGroupMatcher.hasCloneGroup;
 
 public abstract class DetectorTestCase {
@@ -51,11 +57,11 @@ public abstract class DetectorTestCase {
    */
   protected static Block newBlock(String resourceId, ByteArray hash, int index) {
     return Block.builder()
-        .setResourceId(resourceId)
-        .setBlockHash(hash)
-        .setIndexInFile(index)
-        .setLines(index, index + LINES_PER_BLOCK)
-        .build();
+      .setResourceId(resourceId)
+      .setBlockHash(hash)
+      .setIndexInFile(index)
+      .setLines(index, index + LINES_PER_BLOCK)
+      .build();
   }
 
   protected static ClonePart newClonePart(String resourceId, int unitStart, int cloneUnitLength) {
@@ -80,8 +86,8 @@ public abstract class DetectorTestCase {
   @Test
   public void exampleFromPaper() {
     CloneIndex index = createIndex(
-        newBlocks("y", "2 3 4 5"),
-        newBlocks("z", "3 4"));
+      newBlocks("y", "2 3 4 5"),
+      newBlocks("z", "3 4"));
     Block[] fileBlocks = newBlocks("x", "1 2 3 4 5 6");
     List<CloneGroup> result = detect(index, fileBlocks);
 
@@ -89,13 +95,13 @@ public abstract class DetectorTestCase {
     assertEquals(2, result.size());
 
     assertThat(result, hasCloneGroup(4,
-        newClonePart("x", 1, 4),
-        newClonePart("y", 0, 4)));
+      newClonePart("x", 1, 4),
+      newClonePart("y", 0, 4)));
 
     assertThat(result, hasCloneGroup(2,
-        newClonePart("x", 2, 2),
-        newClonePart("y", 1, 2),
-        newClonePart("z", 0, 2)));
+      newClonePart("x", 2, 2),
+      newClonePart("y", 1, 2),
+      newClonePart("z", 0, 2)));
   }
 
   /**
@@ -114,8 +120,8 @@ public abstract class DetectorTestCase {
   @Test
   public void exampleFromPaperWithModifiedResourceIds() {
     CloneIndex cloneIndex = createIndex(
-        newBlocks("a", "2 3 4 5"),
-        newBlocks("b", "3 4"));
+      newBlocks("a", "2 3 4 5"),
+      newBlocks("b", "3 4"));
     Block[] fileBlocks = newBlocks("c", "1 2 3 4 5 6");
     List<CloneGroup> clones = detect(cloneIndex, fileBlocks);
 
@@ -123,13 +129,13 @@ public abstract class DetectorTestCase {
     assertThat(clones.size(), is(2));
 
     assertThat(clones, hasCloneGroup(4,
-        newClonePart("c", 1, 4),
-        newClonePart("a", 0, 4)));
+      newClonePart("c", 1, 4),
+      newClonePart("a", 0, 4)));
 
     assertThat(clones, hasCloneGroup(2,
-        newClonePart("c", 2, 2),
-        newClonePart("a", 1, 2),
-        newClonePart("b", 0, 2)));
+      newClonePart("c", 2, 2),
+      newClonePart("a", 1, 2),
+      newClonePart("b", 0, 2)));
   }
 
   /**
@@ -149,8 +155,8 @@ public abstract class DetectorTestCase {
   @Test
   public void example1() {
     CloneIndex index = createIndex(
-        newBlocks("b", "3 4 5 6"),
-        newBlocks("c", "5 6 7"));
+      newBlocks("b", "3 4 5 6"),
+      newBlocks("c", "5 6 7"));
     Block[] fileBlocks = newBlocks("a", "1 2 3 4 5 6 7 8 9");
     List<CloneGroup> result = detect(index, fileBlocks);
 
@@ -158,17 +164,17 @@ public abstract class DetectorTestCase {
     assertThat(result.size(), is(3));
 
     assertThat(result, hasCloneGroup(4,
-        newClonePart("a", 2, 4),
-        newClonePart("b", 0, 4)));
+      newClonePart("a", 2, 4),
+      newClonePart("b", 0, 4)));
 
     assertThat(result, hasCloneGroup(3,
-        newClonePart("a", 4, 3),
-        newClonePart("c", 0, 3)));
+      newClonePart("a", 4, 3),
+      newClonePart("c", 0, 3)));
 
     assertThat(result, hasCloneGroup(2,
-        newClonePart("a", 4, 2),
-        newClonePart("b", 2, 2),
-        newClonePart("c", 0, 2)));
+      newClonePart("a", 4, 2),
+      newClonePart("b", 2, 2),
+      newClonePart("c", 0, 2)));
   }
 
   /**
@@ -186,8 +192,8 @@ public abstract class DetectorTestCase {
   @Test
   public void example2() {
     CloneIndex index = createIndex(
-        newBlocks("b", "1 2 3 4 1 2 3 4 1 2 3 4"),
-        newBlocks("c", "1 2 3 4"));
+      newBlocks("b", "1 2 3 4 1 2 3 4 1 2 3 4"),
+      newBlocks("c", "1 2 3 4"));
     Block[] fileBlocks = newBlocks("a", "1 2 3 5");
     List<CloneGroup> result = detect(index, fileBlocks);
 
@@ -195,11 +201,11 @@ public abstract class DetectorTestCase {
     assertThat(result.size(), is(1));
 
     assertThat(result, hasCloneGroup(3,
-        newClonePart("a", 0, 3),
-        newClonePart("b", 0, 3),
-        newClonePart("b", 4, 3),
-        newClonePart("b", 8, 3),
-        newClonePart("c", 0, 3)));
+      newClonePart("a", 0, 3),
+      newClonePart("b", 0, 3),
+      newClonePart("b", 4, 3),
+      newClonePart("b", 8, 3),
+      newClonePart("c", 0, 3)));
   }
 
   /**
@@ -223,8 +229,8 @@ public abstract class DetectorTestCase {
     assertThat(result.size(), is(1));
 
     assertThat(result, hasCloneGroup(2,
-        newClonePart("a", 0, 2),
-        newClonePart("a", 3, 2)));
+      newClonePart("a", 0, 2),
+      newClonePart("a", 3, 2)));
   }
 
   /**
@@ -243,7 +249,7 @@ public abstract class DetectorTestCase {
   @Test
   public void covered() {
     CloneIndex index = createIndex(
-        newBlocks("b", "1 2 1 2"));
+      newBlocks("b", "1 2 1 2"));
     Block[] fileBlocks = newBlocks("a", "1 2 1");
     List<CloneGroup> result = detect(index, fileBlocks);
 
@@ -251,13 +257,13 @@ public abstract class DetectorTestCase {
     assertThat(result.size(), is(2));
 
     assertThat(result, hasCloneGroup(3,
-        newClonePart("a", 0, 3),
-        newClonePart("b", 0, 3)));
+      newClonePart("a", 0, 3),
+      newClonePart("b", 0, 3)));
 
     assertThat(result, hasCloneGroup(2,
-        newClonePart("a", 0, 2),
-        newClonePart("b", 0, 2),
-        newClonePart("b", 2, 2)));
+      newClonePart("a", 0, 2),
+      newClonePart("b", 0, 2),
+      newClonePart("b", 2, 2)));
   }
 
   /**
@@ -275,7 +281,7 @@ public abstract class DetectorTestCase {
   @Test
   public void problemWithNestedCloneGroups() {
     CloneIndex index = createIndex(
-        newBlocks("b", "1 2 1 2 1 2 1"));
+      newBlocks("b", "1 2 1 2 1 2 1"));
     Block[] fileBlocks = newBlocks("a", "1 2 1 2 1 2");
     List<CloneGroup> result = detect(index, fileBlocks);
 
@@ -283,13 +289,13 @@ public abstract class DetectorTestCase {
     assertThat(result.size(), is(2));
 
     assertThat(result, hasCloneGroup(6,
-        newClonePart("a", 0, 6),
-        newClonePart("b", 0, 6)));
+      newClonePart("a", 0, 6),
+      newClonePart("b", 0, 6)));
 
     assertThat(result, hasCloneGroup(5,
-        newClonePart("a", 0, 5),
-        newClonePart("b", 0, 5),
-        newClonePart("b", 2, 5)));
+      newClonePart("a", 0, 5),
+      newClonePart("b", 0, 5),
+      newClonePart("b", 2, 5)));
   }
 
   /**
@@ -307,8 +313,8 @@ public abstract class DetectorTestCase {
   @Test
   public void fileAlreadyInIndex() {
     CloneIndex index = createIndex(
-        newBlocks("a", "1 2 3"),
-        newBlocks("b", "1 2 4"));
+      newBlocks("a", "1 2 3"),
+      newBlocks("b", "1 2 4"));
     // Note about blocks with hashes "3", "4" and "5": those blocks here in order to not face another problem - with EOF (see separate test)
     Block[] fileBlocks = newBlocks("a", "1 2 5");
     List<CloneGroup> result = detect(index, fileBlocks);
@@ -317,8 +323,8 @@ public abstract class DetectorTestCase {
     assertThat(result.size(), is(1));
 
     assertThat(result, hasCloneGroup(2,
-        newClonePart("a", 0, 2),
-        newClonePart("b", 0, 2)));
+      newClonePart("a", 0, 2),
+      newClonePart("b", 0, 2)));
   }
 
   /**
@@ -360,17 +366,17 @@ public abstract class DetectorTestCase {
   @Test
   public void problemWithEndOfFile() {
     CloneIndex cloneIndex = createIndex(
-        newBlocks("b", "1 2 3 4"));
+      newBlocks("b", "1 2 3 4"));
     Block[] fileBlocks =
-        newBlocks("a", "1 2 3");
+      newBlocks("a", "1 2 3");
     List<CloneGroup> clones = detect(cloneIndex, fileBlocks);
 
     print(clones);
     assertThat(clones.size(), is(1));
 
     assertThat(clones, hasCloneGroup(3,
-        newClonePart("a", 0, 3),
-        newClonePart("b", 0, 3)));
+      newClonePart("a", 0, 3),
+      newClonePart("b", 0, 3)));
   }
 
   /**
@@ -391,9 +397,9 @@ public abstract class DetectorTestCase {
   public void same_lines_but_different_indexes() {
     CloneIndex cloneIndex = createIndex();
     Block.Builder block = Block.builder()
-        .setResourceId("a")
-        .setLines(0, 1);
-    Block[] fileBlocks = new Block[] {
+      .setResourceId("a")
+      .setLines(0, 1);
+    Block[] fileBlocks = new Block[]{
       block.setBlockHash(new ByteArray("1".getBytes())).setIndexInFile(0).build(),
       block.setBlockHash(new ByteArray("2".getBytes())).setIndexInFile(1).build(),
       block.setBlockHash(new ByteArray("1".getBytes())).setIndexInFile(2).build()
index 4b63abc419e7c8c2b00b1e821f30a095df08b3d7..9831f4531cb6e7c2f25337b54ece9ecd06f50c7f 100644 (file)
@@ -22,7 +22,7 @@ package org.sonar.duplications.detector.original;
 import org.junit.Test;
 import org.sonar.duplications.block.Block;
 
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
 public class BlocksGroupTest {
index ea16c856685cec0fb7bd95c6ce0bc33d00a22c53..8c11dc4ebaef48912b4bb740f665734fcd34dbbc 100644 (file)
@@ -29,7 +29,7 @@ import org.junit.Test;
 import java.io.IOException;
 import java.util.List;
 
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
 public class TokenizerBridgeTest {
index 66fa6dc8294cbdf7e59af1b22fff2996b704157c..96818f6675206443fa3613bec956bbd53914c5a5 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.duplications.token.TokenChunker;
 import java.util.Collection;
 import java.util.List;
 
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 
 /**
index bd0e07d598c9f68b5e6d5b0c23fea6a0356d4a30..5995290c307e67ee7b79e26ab893a28cc76a26e5 100644 (file)
@@ -34,9 +34,7 @@ import java.io.InputStreamReader;
 import java.io.Reader;
 import java.util.List;
 
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class JavaStatementBuilderTest {
 
@@ -49,12 +47,12 @@ public class JavaStatementBuilderTest {
 
   @Test
   public void shouldIgnoreImportStatement() {
-    assertThat(chunk("import org.sonar.duplications.java;").size(), is(0));
+    assertThat(chunk("import org.sonar.duplications.java;")).isEmpty();
   }
 
   @Test
   public void shouldIgnorePackageStatement() {
-    assertThat(chunk("package org.sonar.duplications.java;").size(), is(0));
+    assertThat(chunk("package org.sonar.duplications.java;")).isEmpty();
   }
 
   @Test
@@ -63,66 +61,66 @@ public class JavaStatementBuilderTest {
       "@Entity" +
       "@Table(name = \"properties\")" +
       "@Column(updatable = true, nullable = true)");
-    assertThat(statements.size(), is(3));
-    assertThat(statements.get(0).getValue(), is("@Entity"));
-    assertThat(statements.get(1).getValue(), is("@Table(name=$CHARS)"));
-    assertThat(statements.get(2).getValue(), is("@Column(updatable=true,nullable=true)"));
+    assertThat(statements).hasSize(3);
+    assertThat(statements.get(0).getValue()).isEqualTo("@Entity");
+    assertThat(statements.get(1).getValue()).isEqualTo("@Table(name=$CHARS)");
+    assertThat(statements.get(2).getValue()).isEqualTo("@Column(updatable=true,nullable=true)");
   }
 
   @Test
   public void shouldHandleIf() {
     List<Statement> statements = chunk("if (a > b) { something(); }");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("if(a>b)"));
-    assertThat(statements.get(1).getValue(), is("something()"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("if(a>b)");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
 
     statements = chunk("if (a > b) { something(); } else { somethingOther(); }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("if(a>b)"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("else"));
-    assertThat(statements.get(3).getValue(), is("somethingOther()"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("if(a>b)");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("else");
+    assertThat(statements.get(3).getValue()).isEqualTo("somethingOther()");
 
     statements = chunk("if (a > 0) { something(); } else if (a == 0) { somethingOther(); }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("if(a>$NUMBER)"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("elseif(a==$NUMBER)"));
-    assertThat(statements.get(3).getValue(), is("somethingOther()"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("if(a>$NUMBER)");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("elseif(a==$NUMBER)");
+    assertThat(statements.get(3).getValue()).isEqualTo("somethingOther()");
   }
 
   @Test
   public void shouldHandleFor() {
     List<Statement> statements = chunk("for (int i = 0; i < 10; i++) { something(); }");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("for(inti=$NUMBER;i<$NUMBER;i++)"));
-    assertThat(statements.get(1).getValue(), is("something()"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("for(inti=$NUMBER;i<$NUMBER;i++)");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
 
     statements = chunk("for (Item item : items) { something(); }");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("for(Itemitem:items)"));
-    assertThat(statements.get(1).getValue(), is("something()"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("for(Itemitem:items)");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
   }
 
   @Test
   public void shouldHandleWhile() {
     List<Statement> statements = chunk("while (i < args.length) { something(); }");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("while(i<args.length)"));
-    assertThat(statements.get(1).getValue(), is("something()"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("while(i<args.length)");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
 
     statements = chunk("while (true);");
-    assertThat(statements.size(), is(1));
-    assertThat(statements.get(0).getValue(), is("while(true)"));
+    assertThat(statements.size()).isEqualTo(1);
+    assertThat(statements.get(0).getValue()).isEqualTo("while(true)");
   }
 
   @Test
   public void shouldHandleDoWhile() {
     List<Statement> statements = chunk("do { something(); } while (true);");
-    assertThat(statements.size(), is(3));
-    assertThat(statements.get(0).getValue(), is("do"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("while(true)"));
+    assertThat(statements.size()).isEqualTo(3);
+    assertThat(statements.get(0).getValue()).isEqualTo("do");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("while(true)");
   }
 
   @Test
@@ -133,13 +131,13 @@ public class JavaStatementBuilderTest {
       "  case 2 : monthString=\"February\"; break;" +
       "  default: monthString=\"Invalid\";" +
       "}");
-    assertThat(statements.size(), is(6));
-    assertThat(statements.get(0).getValue(), is("switch(month)"));
-    assertThat(statements.get(1).getValue(), is("case$NUMBER:monthString=$CHARS"));
-    assertThat(statements.get(2).getValue(), is("break"));
-    assertThat(statements.get(3).getValue(), is("case$NUMBER:monthString=$CHARS"));
-    assertThat(statements.get(4).getValue(), is("break"));
-    assertThat(statements.get(5).getValue(), is("default:monthString=$CHARS"));
+    assertThat(statements.size()).isEqualTo(6);
+    assertThat(statements.get(0).getValue()).isEqualTo("switch(month)");
+    assertThat(statements.get(1).getValue()).isEqualTo("case$NUMBER:monthString=$CHARS");
+    assertThat(statements.get(2).getValue()).isEqualTo("break");
+    assertThat(statements.get(3).getValue()).isEqualTo("case$NUMBER:monthString=$CHARS");
+    assertThat(statements.get(4).getValue()).isEqualTo("break");
+    assertThat(statements.get(5).getValue()).isEqualTo("default:monthString=$CHARS");
   }
 
   /**
@@ -152,20 +150,20 @@ public class JavaStatementBuilderTest {
       "  case 'a': case 'b': case 'c': something(); break;" +
       "  case 'd': case 'e': case 'f': somethingOther(); break;" +
       "}");
-    assertThat(statements.size(), is(5));
-    assertThat(statements.get(0).getValue(), is("switch(a)"));
-    assertThat(statements.get(1).getValue(), is("case$CHARS:case$CHARS:case$CHARS:something()"));
-    assertThat(statements.get(2).getValue(), is("break"));
-    assertThat(statements.get(3).getValue(), is("case$CHARS:case$CHARS:case$CHARS:somethingOther()"));
-    assertThat(statements.get(4).getValue(), is("break"));
+    assertThat(statements.size()).isEqualTo(5);
+    assertThat(statements.get(0).getValue()).isEqualTo("switch(a)");
+    assertThat(statements.get(1).getValue()).isEqualTo("case$CHARS:case$CHARS:case$CHARS:something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("break");
+    assertThat(statements.get(3).getValue()).isEqualTo("case$CHARS:case$CHARS:case$CHARS:somethingOther()");
+    assertThat(statements.get(4).getValue()).isEqualTo("break");
   }
 
   @Test
   public void shouldHandleArray() {
     List<Statement> statements = chunk("new Integer[] { 1, 2, 3, 4 };");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("newInteger[]"));
-    assertThat(statements.get(1).getValue(), is("{$NUMBER,$NUMBER,$NUMBER,$NUMBER}"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("newInteger[]");
+    assertThat(statements.get(1).getValue()).isEqualTo("{$NUMBER,$NUMBER,$NUMBER,$NUMBER}");
   }
 
   /**
@@ -174,95 +172,95 @@ public class JavaStatementBuilderTest {
   @Test
   public void shouldHandleMultidimensionalArray() {
     List<Statement> statements = chunk("new Integer[][] { { 1, 2 }, {3, 4} };");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("newInteger[][]"));
-    assertThat(statements.get(1).getValue(), is("{{$NUMBER,$NUMBER},{$NUMBER,$NUMBER}}"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("newInteger[][]");
+    assertThat(statements.get(1).getValue()).isEqualTo("{{$NUMBER,$NUMBER},{$NUMBER,$NUMBER}}");
 
     statements = chunk("new Integer[][] { null, {3, 4} };");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("newInteger[][]"));
-    assertThat(statements.get(1).getValue(), is("{null,{$NUMBER,$NUMBER}}"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("newInteger[][]");
+    assertThat(statements.get(1).getValue()).isEqualTo("{null,{$NUMBER,$NUMBER}}");
   }
 
   @Test
   public void shouldHandleTryCatch() {
     List<Statement> statements;
     statements = chunk("try { } catch (Exception e) { }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("{}"));
-    assertThat(statements.get(2).getValue(), is("catch(Exceptione)"));
-    assertThat(statements.get(3).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exceptione)");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } catch (Exception e) { }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("catch(Exceptione)"));
-    assertThat(statements.get(3).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exceptione)");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } catch (Exception e) { onException(); }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("catch(Exceptione)"));
-    assertThat(statements.get(3).getValue(), is("onException()"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exceptione)");
+    assertThat(statements.get(3).getValue()).isEqualTo("onException()");
 
     statements = chunk("try { something(); } catch (Exception1 e) { onException1(); } catch (Exception2 e) { onException2(); }");
-    assertThat(statements.size(), is(6));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("catch(Exception1e)"));
-    assertThat(statements.get(3).getValue(), is("onException1()"));
-    assertThat(statements.get(4).getValue(), is("catch(Exception2e)"));
-    assertThat(statements.get(5).getValue(), is("onException2()"));
+    assertThat(statements.size()).isEqualTo(6);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exception1e)");
+    assertThat(statements.get(3).getValue()).isEqualTo("onException1()");
+    assertThat(statements.get(4).getValue()).isEqualTo("catch(Exception2e)");
+    assertThat(statements.get(5).getValue()).isEqualTo("onException2()");
   }
 
   @Test
   public void shouldHandleTryFinnaly() {
     List<Statement> statements;
     statements = chunk("try { } finally { }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("{}"));
-    assertThat(statements.get(2).getValue(), is("finally"));
-    assertThat(statements.get(3).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
+    assertThat(statements.get(2).getValue()).isEqualTo("finally");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } finally { }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("finally"));
-    assertThat(statements.get(3).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("finally");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } finally { somethingOther(); }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("finally"));
-    assertThat(statements.get(3).getValue(), is("somethingOther()"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("finally");
+    assertThat(statements.get(3).getValue()).isEqualTo("somethingOther()");
   }
 
   @Test
   public void shouldHandleTryCatchFinally() {
     List<Statement> statements;
     statements = chunk("try { } catch (Exception e) {} finally { }");
-    assertThat(statements.size(), is(6));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("{}"));
-    assertThat(statements.get(2).getValue(), is("catch(Exceptione)"));
-    assertThat(statements.get(3).getValue(), is("{}"));
-    assertThat(statements.get(4).getValue(), is("finally"));
-    assertThat(statements.get(5).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(6);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exceptione)");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
+    assertThat(statements.get(4).getValue()).isEqualTo("finally");
+    assertThat(statements.get(5).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } catch (Exception e) { onException(); } finally { somethingOther(); }");
-    assertThat(statements.size(), is(6));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("catch(Exceptione)"));
-    assertThat(statements.get(3).getValue(), is("onException()"));
-    assertThat(statements.get(4).getValue(), is("finally"));
-    assertThat(statements.get(5).getValue(), is("somethingOther()"));
+    assertThat(statements.size()).isEqualTo(6);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exceptione)");
+    assertThat(statements.get(3).getValue()).isEqualTo("onException()");
+    assertThat(statements.get(4).getValue()).isEqualTo("finally");
+    assertThat(statements.get(5).getValue()).isEqualTo("somethingOther()");
   }
 
   /**
@@ -272,25 +270,25 @@ public class JavaStatementBuilderTest {
   public void shouldHandleMultiCatch() {
     List<Statement> statements;
     statements = chunk("try { } catch (Exception1 | Exception2 e) { }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("{}"));
-    assertThat(statements.get(2).getValue(), is("catch(Exception1|Exception2e)"));
-    assertThat(statements.get(3).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exception1|Exception2e)");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } catch (Exception1 | Exception2 e) { }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("catch(Exception1|Exception2e)"));
-    assertThat(statements.get(3).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exception1|Exception2e)");
+    assertThat(statements.get(3).getValue()).isEqualTo("{}");
 
     statements = chunk("try { something(); } catch (Exception1 | Exception2 e) { onException(); }");
-    assertThat(statements.size(), is(4));
-    assertThat(statements.get(0).getValue(), is("try"));
-    assertThat(statements.get(1).getValue(), is("something()"));
-    assertThat(statements.get(2).getValue(), is("catch(Exception1|Exception2e)"));
-    assertThat(statements.get(3).getValue(), is("onException()"));
+    assertThat(statements.size()).isEqualTo(4);
+    assertThat(statements.get(0).getValue()).isEqualTo("try");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
+    assertThat(statements.get(2).getValue()).isEqualTo("catch(Exception1|Exception2e)");
+    assertThat(statements.get(3).getValue()).isEqualTo("onException()");
   }
 
   /**
@@ -300,30 +298,30 @@ public class JavaStatementBuilderTest {
   public void shouldHandleTryWithResource() {
     List<Statement> statements;
     statements = chunk("try (FileInputStream in = new FileInputStream()) {}");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("try(FileInputStreamin=newFileInputStream())"));
-    assertThat(statements.get(1).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("try(FileInputStreamin=newFileInputStream())");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
 
     statements = chunk("try (FileInputStream in = new FileInputStream(); FileOutputStream out = new FileOutputStream()) {}");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("try(FileInputStreamin=newFileInputStream();FileOutputStreamout=newFileOutputStream())"));
-    assertThat(statements.get(1).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("try(FileInputStreamin=newFileInputStream();FileOutputStreamout=newFileOutputStream())");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
 
     statements = chunk("try (FileInputStream in = new FileInputStream(); FileOutputStream out = new FileOutputStream();) {}");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("try(FileInputStreamin=newFileInputStream();FileOutputStreamout=newFileOutputStream();)"));
-    assertThat(statements.get(1).getValue(), is("{}"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("try(FileInputStreamin=newFileInputStream();FileOutputStreamout=newFileOutputStream();)");
+    assertThat(statements.get(1).getValue()).isEqualTo("{}");
 
     statements = chunk("try (FileInputStream in = new FileInputStream()) { something(); }");
-    assertThat(statements.size(), is(2));
-    assertThat(statements.get(0).getValue(), is("try(FileInputStreamin=newFileInputStream())"));
-    assertThat(statements.get(1).getValue(), is("something()"));
+    assertThat(statements.size()).isEqualTo(2);
+    assertThat(statements.get(0).getValue()).isEqualTo("try(FileInputStreamin=newFileInputStream())");
+    assertThat(statements.get(1).getValue()).isEqualTo("something()");
   }
 
   @Test
   public void realExamples() {
-    assertThat(chunk(DuplicationsTestUtil.findFile("/java/MessageResources.java")).size(), greaterThan(0));
-    assertThat(chunk(DuplicationsTestUtil.findFile("/java/RequestUtils.java")).size(), greaterThan(0));
+    assertThat(chunk(DuplicationsTestUtil.findFile("/java/MessageResources.java")).size()).isGreaterThan(0);
+    assertThat(chunk(DuplicationsTestUtil.findFile("/java/RequestUtils.java")).size()).isGreaterThan(0);
   }
 
   private List<Statement> chunk(File file) {
index 33bf33a0f0ae0791058b29b6da0f88b544fc7d47..93ff6fc6c34f5a84491fcf0efbd9ee34e3b2ba6d 100644 (file)
@@ -37,8 +37,8 @@ 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.hamcrest.number.OrderingComparisons.greaterThan;
 import static org.junit.Assert.assertThat;
 
 public class JavaTokenProducerTest {
index c3f6e6450b84ad87fe1e5d3194803142c39cc147..12d89238fc0fa44b7476fb22eeafbcf6c0446550 100644 (file)
@@ -19,7 +19,7 @@
  */
 package org.sonar.duplications.statement;
 
-import static org.hamcrest.Matchers.is;
+import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
index 6cbeaeb0145e9df0d89228864b6433d7f1d1ae7c..fa845303942eac75348a53ac8abae91905fb545d 100644 (file)
  */
 package org.sonar.duplications.token;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verifyZeroInteractions;
-
 import org.junit.Test;
 import org.sonar.channel.CodeReader;
 
+import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verifyZeroInteractions;
+
 public class BlackHoleTokenChannelTest {
 
   @Test
@@ -35,9 +34,9 @@ public class BlackHoleTokenChannelTest {
     TokenQueue output = mock(TokenQueue.class);
     CodeReader codeReader = new CodeReader("ABCD");
 
-    assertThat(channel.consume(codeReader, output), is(true));
-    assertThat(codeReader.getLinePosition(), is(1));
-    assertThat(codeReader.getColumnPosition(), is(3));
+    assertThat(channel.consume(codeReader, output)).isTrue();
+    assertThat(codeReader.getLinePosition()).isEqualTo(1);
+    assertThat(codeReader.getColumnPosition()).isEqualTo(3);
     verifyZeroInteractions(output);
   }
 
index 6fda53df33128cb7f00553d1851911d867a25e29..55bcb1bfff09ed943eff744348cd01427589e705 100644 (file)
  */
 package org.sonar.api.database.model;
 
-import org.hamcrest.core.Is;
 import org.junit.Test;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.internal.matchers.StringContains.containsString;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class UserTest {
 
   @Test
   public void testToString() {
     User user = new User()
-        .setEmail("super@m.an")
-        .setLogin("superman")
-        .setName("Superman");
-    assertThat(user.toString(), containsString("super@m.an"));
-    assertThat(user.toString(), containsString("superman"));
-    assertThat(user.toString(), containsString("Superman"));
+      .setEmail("super@m.an")
+      .setLogin("superman")
+      .setName("Superman");
+    assertThat(user.toString()).contains("super@m.an");
+    assertThat(user.toString()).contains("superman");
+    assertThat(user.toString()).contains("Superman");
   }
 
   @Test
   public void testEquals() {
     User one = new User()
-        .setLogin("one")
-        .setName("One");
+      .setLogin("one")
+      .setName("One");
 
     User two = new User()
-        .setLogin("two")
-        .setName("Two");
+      .setLogin("two")
+      .setName("Two");
 
-    assertThat(one.equals(one), Is.is(true));
-    assertThat(one.equals(new User().setLogin("one")), Is.is(true));
-    assertThat(one.equals(two), Is.is(false));
+    assertThat(one.equals(one)).isTrue();
+    assertThat(one.equals(new User().setLogin("one"))).isTrue();
+    assertThat(one.equals(two)).isFalse();
 
-    assertEquals(one.hashCode(), new User().setLogin("one").hashCode());
+    assertThat(one.hashCode()).isEqualTo(new User().setLogin("one").hashCode());
   }
 }
index 7f0000faea742e4c8d25f71bb737648ae4fe9438..2a891daa0895832bbb7668429e3aa2803f76e74f 100644 (file)
@@ -34,23 +34,20 @@ import java.util.jar.Attributes;
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
-import static org.junit.matchers.JUnitMatchers.hasItems;
+import static org.fest.assertions.Assertions.assertThat;
 
 public class ManifestUtilsTest {
 
   @Rule
   public TemporaryFolder tempDir = new TemporaryFolder();
 
-    @Test
+  @Test
   public void emptyManifest() throws Exception {
     Manifest mf = new Manifest();
     File jar = createJar(mf, "emptyManifest.jar");
 
     URLClassLoader classloader = new URLClassLoader(FileUtils.toURLs(new File[]{jar}));
-    assertThat(ManifestUtils.getPropertyValues(classloader, "foo").size(), is(0));
+    assertThat(ManifestUtils.getPropertyValues(classloader, "foo")).isEmpty();
   }
 
   @Test
@@ -62,8 +59,7 @@ public class ManifestUtilsTest {
 
     URLClassLoader classloader = new URLClassLoader(FileUtils.toURLs(new File[]{jar}));
     List<String> values = ManifestUtils.getPropertyValues(classloader, "foo");
-    assertThat(values.size(), is(1));
-    assertThat(values, hasItem("bar"));
+    assertThat(values).containsOnly("bar");
   }
 
   @Test
@@ -78,8 +74,7 @@ public class ManifestUtilsTest {
 
     URLClassLoader classloader = new URLClassLoader(FileUtils.toURLs(new File[]{jar1, jar2}));
     List<String> values = ManifestUtils.getPropertyValues(classloader, "foo");
-    assertThat(values.size(), is(2));
-    assertThat(values, hasItems("bar", "otherbar"));
+    assertThat(values).containsOnly("bar", "otherbar");
   }
 
   private File createJar(Manifest mf, String name) throws Exception {
index 86ccebc95bb31eea9162bb4e9aaf0923e99c67b2..a69e4ab7edf1264f699c0f274783c3f5ac605c9c 100644 (file)
@@ -22,21 +22,21 @@ package org.sonar.api.utils;
 import org.junit.Test;
 import org.slf4j.Logger;
 
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-import static org.junit.internal.matchers.IsCollectionContaining.hasItem;
-import static org.junit.internal.matchers.StringContains.containsString;
+import static org.fest.assertions.Assertions.assertThat;
 import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 
 public class ValidationMessagesTest {
 
   @Test
   public void emptyMessages() {
     ValidationMessages messages = ValidationMessages.create();
-    assertThat(messages.hasErrors(), is(false));
-    assertThat(messages.hasWarnings(), is(false));
-    assertThat(messages.hasInfos(), is(false));
+    assertThat(messages.hasErrors()).isFalse();
+    assertThat(messages.hasWarnings()).isFalse();
+    assertThat(messages.hasInfos()).isFalse();
 
     Logger logger = mock(Logger.class);
     messages.log(logger);
@@ -49,13 +49,13 @@ public class ValidationMessagesTest {
   public void addError() {
     ValidationMessages messages = ValidationMessages.create();
     messages.addErrorText("my error");
-    assertThat(messages.hasErrors(), is(true));
-    assertThat(messages.hasWarnings(), is(false));
-    assertThat(messages.hasInfos(), is(false));
-    assertThat(messages.getErrors().size(), is(1));
-    assertThat(messages.getErrors(), hasItem("my error"));
-    assertThat(messages.toString(), containsString("my error"));
-    
+    assertThat(messages.hasErrors()).isTrue();
+    assertThat(messages.hasWarnings()).isFalse();
+    assertThat(messages.hasInfos()).isFalse();
+    assertThat(messages.getErrors()).hasSize(1);
+    assertThat(messages.getErrors()).contains("my error");
+    assertThat(messages.toString()).contains("my error");
+
     Logger logger = mock(Logger.class);
     messages.log(logger);
     verify(logger, times(1)).error("my error");
index 518bc8a9f0efec159c59d6018e7f361162dd1ecc..b38918329938de15b734711032366fe0b96094e5 100644 (file)
@@ -49,7 +49,7 @@ public class CommandExecutorTest {
   private File workDir;
 
   @Before
-  public void setUp() {
+  public void before() throws IOException {
     workDir = tempFolder.newFolder(testName.getMethodName());
   }
 
index 4a57f7c8bfa88c40baf38a3ffc2275d1341315a2..9b798cee8d8dfbcb73c9c1cafe50be7c191834b7 100644 (file)
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</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>
               </resources>
             </configuration>
           </execution>
+          <execution>
+            <id>copy-generated-webapp</id>
+            <!-- must be after the execution of grunt -->
+            <phase>process-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
+              <overwrite>true</overwrite>
+              <resources>
+                <resource>
+                  <directory>src/main/webapp/build</directory>
+                  <filtering>false</filtering>
+                </resource>
+              </resources>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>
           </execution>
         </executions>
       </plugin>
-      <plugin>
-        <artifactId>maven-resources-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>copy-generated-webapp</id>
-            <!-- must be after the execution of grunt -->
-            <phase>process-resources</phase>
-            <goals>
-              <goal>copy-resources</goal>
-            </goals>
-            <configuration>
-              <outputDirectory>${project.build.directory}/${project.build.finalName}</outputDirectory>
-              <overwrite>true</overwrite>
-              <resources>
-                <resource>
-                  <directory>src/main/webapp/build</directory>
-                  <filtering>false</filtering>
-                </resource>
-              </resources>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-war-plugin</artifactId>
             </executions>
           </plugin>
           <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-resources-plugin</artifactId>
             <executions>
               <execution>
index 94a18f4ff4431f78c174b26c6ad5c84cc9a866be..e7f899a06c7f62c1da850d8062139b40489d549c 100644 (file)
  */
 package org.sonar.wsclient.services;
 
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertThat;
-
 import org.junit.Test;
 
+import static org.fest.assertions.Assertions.assertThat;
+
 public class ServerSetupQueryTest extends QueryTestCase {
   @Test
   public void index() {
     ServerSetupQuery query = new ServerSetupQuery();
-    assertThat(query.getUrl(), is("/api/server/setup"));
-    assertThat(query.getModelClass().getName(), is(ServerSetup.class.getName()));
+    assertThat(query.getUrl()).isEqualTo("/api/server/setup");
+    assertThat(query.getModelClass().getName()).isEqualTo(ServerSetup.class.getName());
   }
 }
index 551a0597fd827fc35a978d66fde5d3e3df7a0901..4fac008d1a059851050935715a6e8a570ba0ed02 100644 (file)
@@ -24,9 +24,9 @@ import org.sonar.wsclient.services.Resource;
 
 import java.util.List;
 
-import static org.hamcrest.Matchers.nullValue;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
 import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsNot.not;
 import static org.junit.Assert.assertThat;
 
 public class ResourceUnmarshallerTest extends UnmarshallerTestCase {