diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-21 23:41:03 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2014-04-21 23:41:03 +0200 |
commit | cba389dcee6ddd3d0cffd82d4c28beb87e53c58a (patch) | |
tree | 932dcc58798d99302f64de11e63ecea5fcba8320 /sonar-colorizer | |
parent | 30ba10e719b5152c529dc6022f48fe6f5c79dcb7 (diff) | |
download | sonarqube-cba389dcee6ddd3d0cffd82d4c28beb87e53c58a.tar.gz sonarqube-cba389dcee6ddd3d0cffd82d4c28beb87e53c58a.zip |
Continue move from hamcrest to fest-assert
Diffstat (limited to 'sonar-colorizer')
13 files changed, 109 insertions, 139 deletions
diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java index a2436da7b72..7e2616ea209 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/CDocTokenizerTest.java @@ -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>"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java index 889241b0d06..ffb379c0637 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/CaseInsensitiveKeywordsTokenizerTest.java @@ -19,28 +19,26 @@ */ 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"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java index 3c5860d3c82..b60d3d1b683 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/CodeColorizerTest.java @@ -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 <b>something</b></span></pre>", - "<pre><span class=\"cppd\"> *</span></pre>", - "<pre><span class=\"cppd\"> * &lt;p&gt;description&lt;/p&gt;</span></pre>", - "<pre><span class=\"cppd\"> */</span></pre>"); + "<pre><span class=\"cppd\"> * This method does <b>something</b></span></pre>", + "<pre><span class=\"cppd\"> *</span></pre>", + "<pre><span class=\"cppd\"> * &lt;p&gt;description&lt;/p&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); } } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java index 42ec296b0db..60b5880e0ee 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlCodeBuilderTest.java @@ -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 < olivier", builder.toString()); + assertThat("freddy < olivier").isEqualTo(builder.toString()); } @Test @@ -47,35 +44,35 @@ public class HtmlCodeBuilderTest { builder.append('p'); builder.append('a'); builder.append('>'); - assertEquals("pa>", builder.toString()); + assertThat("pa>").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")); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java index eea8b1b580a..00919dfcd7c 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlDecoratorTest.java @@ -19,15 +19,11 @@ */ 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); } } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java index 74d9bc69476..b3176402377 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java @@ -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>\"<html>\"</s>);")); + assertThat(html).isEqualTo("foo(<s>\"<html>\"</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>"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java index 26ad9eb3ed4..0e6ced24860 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaAnnotationTokenizerTest.java @@ -19,24 +19,23 @@ */ 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)"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java index dbab1f20a06..90fd7a22731 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaKeywordsTest.java @@ -19,18 +19,15 @@ */ 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"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java index 98e9706186d..01527269a29 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavaTokenizersTest.java @@ -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) { diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java index 0474a6ceff5..809c27794ff 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/JavadocTokenizerTest.java @@ -19,24 +19,23 @@ */ 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"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java index 086196a6c4a..e36736db923 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/KeywordsTokenizerTest.java @@ -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"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java index c1d0ba47a5a..86475b2587d 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/RegexpTokenizerTest.java @@ -19,29 +19,28 @@ */ 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"); } } diff --git a/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java b/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java index e933ea36443..07548806439 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/TokenizerDispatcherTest.java @@ -19,41 +19,40 @@ */ 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) |