diff options
17 files changed, 50 insertions, 54 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java index 5a58208d902..b5804550322 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrapper/Batch.java @@ -37,7 +37,7 @@ import java.util.Map; public final class Batch { private LoggingConfiguration logging; - private List components; + private List<Object> components; private ProjectReactor projectReactor; private Batch(Builder builder) { 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 c2f168efcad..237e5d2c48a 100644 --- a/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java +++ b/sonar-colorizer/src/test/java/org/sonar/colorizer/HtmlRendererTest.java @@ -19,16 +19,15 @@ */ package org.sonar.colorizer; +import org.apache.commons.io.FileUtils; +import org.junit.Test; + import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.StringReader; import java.util.Arrays; -import org.apache.commons.io.FileUtils; -import org.junit.Test; -import org.sonar.channel.Channel; - import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import static org.junit.internal.matchers.StringContains.containsString; @@ -39,16 +38,18 @@ public class HtmlRendererTest { @Test public void renderJavaSyntax() { - String html = new HtmlRenderer(HtmlOptions.ONLY_SYNTAX).render(new StringReader("public class Hello {"), Arrays - .<Channel<HtmlCodeBuilder>> asList(javaKeywordTokenizer)); + HtmlRenderer htmlRenderer = new HtmlRenderer(HtmlOptions.ONLY_SYNTAX); + + 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 {")); } @Test public void supportHtmlSpecialCharacters() { - String html = new HtmlRenderer(HtmlOptions.ONLY_SYNTAX).render(new StringReader("foo(\"<html>\");"), Arrays - .<Channel<HtmlCodeBuilder>> asList(new LiteralTokenizer("<s>", "</s>"))); + HtmlRenderer htmlRenderer = new HtmlRenderer(HtmlOptions.ONLY_SYNTAX); + + String html = htmlRenderer.render(new StringReader("foo(\"<html>\");"), Arrays.asList(new LiteralTokenizer("<s>", "</s>"))); assertThat(html, is("foo(<s>\"<html>\"</s>);")); } @@ -57,7 +58,7 @@ public class HtmlRendererTest { public void renderJavaFile() throws IOException { File java = FileUtils.toFile(getClass().getResource("/org/sonar/colorizer/HtmlRendererTest/Sample.java")); - String html = new HtmlRenderer().render(new FileReader(java), Arrays.<Channel<HtmlCodeBuilder>> asList(javaKeywordTokenizer)); + String html = new HtmlRenderer().render(new FileReader(java), Arrays.asList(javaKeywordTokenizer)); assertThat(html, containsString("<html>")); assertThat(html, containsString("<style")); diff --git a/sonar-core/pom.xml b/sonar-core/pom.xml index ab91393085a..44ce2aa268f 100644 --- a/sonar-core/pom.xml +++ b/sonar-core/pom.xml @@ -135,6 +135,11 @@ <artifactId>dbunit</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.easytesting</groupId> + <artifactId>fest-assert</artifactId> + <scope>test</scope> + </dependency> <!-- JDBC drivers for MyBatis integration tests. diff --git a/sonar-core/src/test/java/org/sonar/core/rule/DefaultRuleFinderTest.java b/sonar-core/src/test/java/org/sonar/core/rule/DefaultRuleFinderTest.java index b5b9685e815..568b84bf675 100644 --- a/sonar-core/src/test/java/org/sonar/core/rule/DefaultRuleFinderTest.java +++ b/sonar-core/src/test/java/org/sonar/core/rule/DefaultRuleFinderTest.java @@ -23,15 +23,16 @@ import org.junit.Test; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RuleQuery; -import org.sonar.core.rule.DefaultRuleFinder; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.Collection; -import static org.hamcrest.CoreMatchers.anyOf; +import static org.fest.assertions.Assertions.assertThat; import static org.hamcrest.core.Is.is; import static org.hamcrest.core.IsNull.nullValue; -import static org.junit.Assert.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThat; public class DefaultRuleFinderTest extends AbstractDbUnitTestCase { @@ -72,8 +73,8 @@ public class DefaultRuleFinderTest extends AbstractDbUnitTestCase { setupData("shared"); RuleFinder finder = new DefaultRuleFinder(getSessionFactory()); Collection<Rule> rules = finder.findAll(RuleQuery.create().withRepositoryKey("checkstyle")); - assertNotNull(rules); - assertThat(rules.size(), is(2)); // only enabled checkstyle rules + + assertThat(rules).hasSize(2); } @Test @@ -81,11 +82,8 @@ public class DefaultRuleFinderTest extends AbstractDbUnitTestCase { setupData("shared"); RuleFinder finder = new DefaultRuleFinder(getSessionFactory()); Collection<Rule> rules = finder.findAll(RuleQuery.create()); - assertNotNull(rules); - assertThat(rules.size(), is(3)); // only enabled checkstyle+pmd rules - for (Rule rule : rules) { - assertThat(rule.getId(), anyOf(is(1), is(3), is(4))); - } + + assertThat(rules).onProperty("id").containsOnly(1, 3, 4); } @Test diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/BatchExtensionDictionnaryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/BatchExtensionDictionnaryTest.java index 0b6eedbddf8..fe4feda7d5e 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/BatchExtensionDictionnaryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/BatchExtensionDictionnaryTest.java @@ -196,7 +196,6 @@ public class BatchExtensionDictionnaryTest { BatchExtensionDictionnary selector = newSelector(); BatchExtension wrong = new BatchExtension() { @DependsUpon - @SuppressWarnings("unused") private Object foo() { return "foo"; } diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java index 895e37952e6..093fe3576b2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/checks/AnnotationCheckFactoryTest.java @@ -19,7 +19,6 @@ */ package org.sonar.api.checks; -import org.hamcrest.Matcher; import org.junit.Test; import org.junit.rules.ExpectedException; import org.sonar.api.profiles.RulesProfile; @@ -29,9 +28,7 @@ import org.sonar.api.utils.SonarException; import java.util.Arrays; -import static org.hamcrest.Matchers.hasItems; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.nullValue; +import static org.fest.assertions.Assertions.assertThat; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertSame; @@ -167,7 +164,7 @@ public class AnnotationCheckFactoryTest { profile.activateRule(clonedRule, null); AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithKey.class)); - assertThat(factory.getChecks(), (Matcher) not(hasItems(nullValue()))); + assertThat(factory.getChecks()).excludes(new Object[] {null}); } /** diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java index 18421ed4df3..d19ac7e83e2 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/measures/SumChildDistributionFormulaTest.java @@ -60,7 +60,7 @@ public class SumChildDistributionFormulaTest { @Test public void testWhenGetChildrenReturnsEmpty() { when(context.getTargetMetric()).thenReturn(new Metric("foo")); - when(data.getChildrenMeasures(new Metric("foo"))).thenReturn((List) Collections.emptyList()); + when(data.getChildrenMeasures(new Metric("foo"))).thenReturn(Collections.<Measure> emptyList()); assertNull(formula.calculate(data, context)); } diff --git a/sonar-server/src/main/java/org/sonar/server/filters/FilterResult.java b/sonar-server/src/main/java/org/sonar/server/filters/FilterResult.java index a09a3dcfd29..421e53f138e 100644 --- a/sonar-server/src/main/java/org/sonar/server/filters/FilterResult.java +++ b/sonar-server/src/main/java/org/sonar/server/filters/FilterResult.java @@ -30,7 +30,7 @@ public class FilterResult { public static final int SORTED_COLUMN_INDEX = 3; public FilterResult(Filter filter, List rows) { - this.rows = new ArrayList(rows); + this.rows = new ArrayList<Object[]>(rows); this.filter = filter; } diff --git a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java index 65ef210a2cb..a7b5b34efbd 100644 --- a/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java +++ b/sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java @@ -362,7 +362,7 @@ public final class JRubyFacade { } try { - Class aClass = Class.forName(className); + Class<?> aClass = Class.forName(className); return getContainer().getComponentByType(aClass); } catch (ClassNotFoundException e) { @@ -374,7 +374,7 @@ public final class JRubyFacade { public Object getComponentByClassname(String pluginKey, String className) { Object component = null; ComponentContainer container = getContainer(); - Class componentClass = container.getComponentByType(DefaultServerPluginRepository.class).getClass(pluginKey, className); + Class<?> componentClass = container.getComponentByType(DefaultServerPluginRepository.class).getClass(pluginKey, className); if (componentClass != null) { component = container.getComponentByType(componentClass); } diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ServletFiltersTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ServletFiltersTest.java index c6a715c0696..6070b4891bf 100644 --- a/sonar-server/src/test/java/org/sonar/server/platform/ServletFiltersTest.java +++ b/sonar-server/src/test/java/org/sonar/server/platform/ServletFiltersTest.java @@ -22,7 +22,6 @@ package org.sonar.server.platform; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.InOrder; import org.sonar.api.web.ServletFilter; import javax.servlet.*; diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java index 9aa726b1246..a3705488374 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/AbstractnessFormulaTest.java @@ -30,7 +30,7 @@ import static org.junit.Assert.assertEquals; public class AbstractnessFormulaTest { AbstractnessFormula abstractness = new AbstractnessFormula(); - Measurable measurable = new SourcePackage("pac1"); + Measurable<Metric> measurable = new SourcePackage("pac1"); @Test public void testCalculate() { @@ -40,7 +40,7 @@ public class AbstractnessFormulaTest { assertEquals(0.2, abstractness.calculate(measurable), 0); } - + @Test public void testCalculateOnEmptyProject() { measurable.setMeasure(Metric.CLASSES, 0); diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java index 28a4a44fcab..496d62ce963 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesDensityFormulaTest.java @@ -25,11 +25,10 @@ import org.sonar.squid.api.SourceClass; import static org.junit.Assert.*; - public class CommentLinesDensityFormulaTest { - + CommentLinesDensityFormula formula = new CommentLinesDensityFormula(); - Measurable measurable = new SourceClass("com.Toto"); + Measurable<Metric> measurable = new SourceClass("com.Toto"); @Test public void calculateDensityOnEmptyFile() { @@ -37,7 +36,7 @@ public class CommentLinesDensityFormulaTest { measurable.setMeasure(Metric.COMMENT_LINES, 0); assertEquals(0, measurable.getDouble(Metric.COMMENT_LINES_DENSITY), 0.01); } - + @Test public void calculate() { measurable.setMeasure(Metric.LINES_OF_CODE, 10); diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java index 886184546fd..9fb255e3e2c 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/CommentLinesWithoutHeaderFormulaTest.java @@ -27,8 +27,8 @@ import static org.junit.Assert.assertEquals; public class CommentLinesWithoutHeaderFormulaTest { - CommentLinesWithoutHeaderFormula formula = new CommentLinesWithoutHeaderFormula(); - Measurable measurable = new SourceClass("com.Toto"); + CommentLinesWithoutHeaderFormula formula = new CommentLinesWithoutHeaderFormula(); + Measurable<Metric> measurable = new SourceClass("com.Toto"); @Test public void calculateDensityOnEmptyFile() { diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java index f4d4f39eb42..406fb261171 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/DistanceFormulaTest.java @@ -27,8 +27,8 @@ import static org.junit.Assert.assertEquals; public class DistanceFormulaTest { - DistanceFormula distance = new DistanceFormula(); - Measurable measurable = new SourcePackage("pac1"); + DistanceFormula distance = new DistanceFormula(); + Measurable<Metric> measurable = new SourcePackage("pac1"); @Test public void calculateBestDistance() { @@ -38,7 +38,7 @@ public class DistanceFormulaTest { measurable.setMeasure(Metric.CE, 10); assertEquals(0.5, measurable.getDouble(Metric.DISTANCE), 0.01); } - + @Test public void calculateWorstDistance() { measurable.setMeasure(Metric.CLASSES, 5); diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java index 641f227695c..92f3aca2ace 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/InstabilityFormulaTest.java @@ -27,8 +27,8 @@ import static org.junit.Assert.assertEquals; public class InstabilityFormulaTest { - InstabilityFormula distance = new InstabilityFormula(); - Measurable measurable = new SourcePackage("pac1"); + InstabilityFormula distance = new InstabilityFormula(); + Measurable<Metric> measurable = new SourcePackage("pac1"); @Test public void calculateBestStability() { @@ -36,14 +36,14 @@ public class InstabilityFormulaTest { measurable.setMeasure(Metric.CE, 0); assertEquals(0, measurable.getDouble(Metric.INSTABILITY), 0.01); } - + @Test public void calculateWorstStability() { measurable.setMeasure(Metric.CA, 0); measurable.setMeasure(Metric.CE, 10); assertEquals(1, measurable.getDouble(Metric.INSTABILITY), 0.01); } - + @Test public void calculateOnIsolatedProject() { measurable.setMeasure(Metric.CA, 0); diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/MeanAggregationFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/MeanAggregationFormulaTest.java index 84d8ace882d..80796ff9be1 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/MeanAggregationFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/MeanAggregationFormulaTest.java @@ -28,9 +28,8 @@ import static org.junit.Assert.*; import org.sonar.squid.api.SourceClass; - public class MeanAggregationFormulaTest { - + MeanAggregationFormula formula = new MeanAggregationFormula(); @Test @@ -42,10 +41,10 @@ public class MeanAggregationFormulaTest { SourceClass class2 = new SourceClass("com.My"); class2.setMeasure(Metric.COMPLEXITY, 3); measurables.add(class2); - + assertEquals(2.5, formula.aggregate(Metric.COMPLEXITY, measurables), 0.01); } - + @Test public void testAggregateEmptyCollections() { List<Measurable> measurables = new ArrayList<Measurable>(); diff --git a/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java b/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java index bf20ee2c419..bfc38bba206 100644 --- a/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java +++ b/sonar-squid/src/test/java/org/sonar/squid/measures/PublicDocumentedApiDensityFormulaTest.java @@ -25,11 +25,10 @@ import org.sonar.squid.api.SourceClass; import static org.junit.Assert.*; - public class PublicDocumentedApiDensityFormulaTest { - + PublicDocumentedApiDensityFormula formula = new PublicDocumentedApiDensityFormula(); - Measurable measurable = new SourceClass("com.Toto"); + Measurable<Metric> measurable = new SourceClass("com.Toto"); @Test public void calculateWhenNoPublicApi() { @@ -37,7 +36,7 @@ public class PublicDocumentedApiDensityFormulaTest { measurable.setMeasure(Metric.PUBLIC_DOC_API, 0); assertEquals(1, measurable.getDouble(Metric.PUBLIC_DOCUMENTED_API_DENSITY), 0.01); } - + @Test public void calculate() { measurable.setMeasure(Metric.PUBLIC_API, 10); |