diff options
11 files changed, 38 insertions, 31 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java index 1d4a5b7887b..25b8f5520bb 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleProfileImporter.java @@ -21,7 +21,6 @@ package org.sonar.plugins.checkstyle; import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; -import org.codehaus.stax2.XMLInputFactory2; import org.codehaus.staxmate.SMInputFactory; import org.codehaus.staxmate.in.SMHierarchicCursor; import org.codehaus.staxmate.in.SMInputCursor; @@ -79,7 +78,7 @@ public class CheckstyleProfileImporter extends ProfileImporter { } private SMInputFactory initStax() { - XMLInputFactory xmlFactory = XMLInputFactory2.newInstance(); + XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); xmlFactory.setProperty(XMLInputFactory.SUPPORT_DTD, Boolean.FALSE); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/BranchCoverageDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/BranchCoverageDecoratorTest.java index 94bbe724d4c..f20bc69ba81 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/BranchCoverageDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/BranchCoverageDecoratorTest.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.core.sensors; +import org.sonar.api.resources.Resource; + import org.junit.Test; import static org.mockito.Matchers.anyDouble; import static org.mockito.Matchers.eq; @@ -33,8 +35,8 @@ public class BranchCoverageDecoratorTest { @Test public void shouldNotSaveBranchCoverageIfMissingConditions() { Project resource = mock(Project.class); - when(resource.getScope()).thenReturn(Project.SCOPE_SET); - when(resource.getQualifier()).thenReturn(Project.QUALIFIER_SUBVIEW); + when(resource.getScope()).thenReturn(Resource.SCOPE_SET); + when(resource.getQualifier()).thenReturn(Resource.QUALIFIER_SUBVIEW); DecoratorContext context = mockContext(null, null); new BranchCoverageDecorator().decorate(resource, context); @@ -45,8 +47,8 @@ public class BranchCoverageDecoratorTest { @Test public void shouldSaveBranchCoverage() { Project resource = mock(Project.class); - when(resource.getScope()).thenReturn(Project.SCOPE_SET); - when(resource.getQualifier()).thenReturn(Project.QUALIFIER_PROJECT); + when(resource.getScope()).thenReturn(Resource.SCOPE_SET); + when(resource.getQualifier()).thenReturn(Resource.QUALIFIER_PROJECT); DecoratorContext context = mockContext(20, 15); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CheckAlertThresholdsTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CheckAlertThresholdsTest.java index e060808cabf..9d9f3088164 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CheckAlertThresholdsTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CheckAlertThresholdsTest.java @@ -61,7 +61,7 @@ public class CheckAlertThresholdsTest { profile = mock(RulesProfile.class); decorator = new CheckAlertThresholds(profile); project = mock(Resource.class); - when(project.getQualifier()).thenReturn(Project.QUALIFIER_PROJECT); + when(project.getQualifier()).thenReturn(Resource.QUALIFIER_PROJECT); } @Test @@ -85,7 +85,7 @@ public class CheckAlertThresholdsTest { @Test public void checkRootProjectsOnly() { - when(project.getQualifier()).thenReturn(Project.QUALIFIER_FILE); + when(project.getQualifier()).thenReturn(Resource.QUALIFIER_FILE); when(profile.getAlerts()).thenReturn(Arrays.asList( new Alert(null, CoreMetrics.CLASSES, Alert.OPERATOR_GREATER, null, "20"), new Alert(null, CoreMetrics.COVERAGE, Alert.OPERATOR_GREATER, null, "35.0"))); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java index 4ca1016cafa..30067c35fa7 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/CoverageDecoratorTest.java @@ -21,6 +21,9 @@ package org.sonar.plugins.core.sensors; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; + +import org.sonar.api.resources.Resource; + import org.junit.Before; import org.junit.Test; import static org.mockito.Mockito.*; @@ -36,7 +39,7 @@ public class CoverageDecoratorTest { @Before public void before() { project = mock(Project.class); - when(project.getScope()).thenReturn(Project.SCOPE_SET); + when(project.getScope()).thenReturn(Resource.SCOPE_SET); } @Test diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LineCoverageDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LineCoverageDecoratorTest.java index 51bad0da775..fe54290362e 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LineCoverageDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/LineCoverageDecoratorTest.java @@ -21,6 +21,9 @@ package org.sonar.plugins.core.sensors; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; + +import org.sonar.api.resources.Resource; + import org.junit.Before; import org.junit.Test; import static org.mockito.Mockito.*; @@ -36,7 +39,7 @@ public class LineCoverageDecoratorTest { @Before public void before() { project = mock(Project.class); - when(project.getScope()).thenReturn(Project.SCOPE_SET); + when(project.getScope()).thenReturn(Resource.SCOPE_SET); } @Test diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java index 837b95d060b..05eab0ff516 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsExecutor.java @@ -19,6 +19,8 @@ */ package org.sonar.plugins.findbugs; +import edu.umd.cs.findbugs.Priorities; + import com.google.common.collect.Lists; import edu.umd.cs.findbugs.*; import edu.umd.cs.findbugs.config.UserPreferences; @@ -75,7 +77,7 @@ public class FindbugsExecutor implements BatchExtension { engine.setProject(project); XMLBugReporter xmlBugReporter = new XMLBugReporter(project); - xmlBugReporter.setPriorityThreshold(Detector.LOW_PRIORITY); + xmlBugReporter.setPriorityThreshold(Priorities.LOW_PRIORITY); xmlBugReporter.setAddMessages(true); File xmlReport = configuration.getTargetXMLReport(); diff --git a/sonar-batch/src/test/java/org/sonar/batch/DefaultFileLinesContextTest.java b/sonar-batch/src/test/java/org/sonar/batch/DefaultFileLinesContextTest.java index d3f73831031..d84750fd98d 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/DefaultFileLinesContextTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/DefaultFileLinesContextTest.java @@ -19,10 +19,11 @@ */ package org.sonar.batch; +import org.mockito.Matchers; + import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; import org.sonar.api.batch.SonarIndex; import org.sonar.api.measures.Measure; import org.sonar.api.measures.Metric; @@ -62,7 +63,7 @@ public class DefaultFileLinesContextTest { fileLineMeasures.save(); ArgumentCaptor<Measure> measureCaptor = ArgumentCaptor.forClass(Measure.class); - verify(index).addMeasure(Mockito.eq(resource), measureCaptor.capture()); + verify(index).addMeasure(Matchers.eq(resource), measureCaptor.capture()); Measure measure = measureCaptor.getValue(); assertThat(measure.getMetricKey(), is("hits")); assertThat(measure.getPersistenceMode(), is(PersistenceMode.DATABASE)); @@ -80,7 +81,7 @@ public class DefaultFileLinesContextTest { fileLineMeasures.setIntValue("branches", 3, 4); fileLineMeasures.save(); - verify(index, times(3)).addMeasure(Mockito.eq(resource), Mockito.any(Measure.class)); + verify(index, times(3)).addMeasure(Matchers.eq(resource), Matchers.any(Measure.class)); } @Test(expected = UnsupportedOperationException.class) @@ -88,13 +89,13 @@ public class DefaultFileLinesContextTest { fileLineMeasures.setIntValue("hits", 1, 2); fileLineMeasures.save(); fileLineMeasures.save(); - verify(index).addMeasure(Mockito.eq(resource), Mockito.any(Measure.class)); + verify(index).addMeasure(Matchers.eq(resource), Matchers.any(Measure.class)); fileLineMeasures.setIntValue("hits", 1, 2); } @Test public void shouldLoadIntValues() { - when(index.getMeasure(Mockito.any(Resource.class), Mockito.any(Metric.class))) + when(index.getMeasure(Matchers.any(Resource.class), Matchers.any(Metric.class))) .thenReturn(new Measure("hits").setData("1=2;3=4")); assertThat(fileLineMeasures.getIntValue("hits", 1), is(2)); @@ -104,7 +105,7 @@ public class DefaultFileLinesContextTest { @Test public void shouldLoadStringValues() { - when(index.getMeasure(Mockito.any(Resource.class), Mockito.any(Metric.class))) + when(index.getMeasure(Matchers.any(Resource.class), Matchers.any(Metric.class))) .thenReturn(new Measure("author").setData("1=simon;3=evgeny")); assertThat(fileLineMeasures.getStringValue("author", 1), is("simon")); @@ -114,18 +115,18 @@ public class DefaultFileLinesContextTest { @Test public void shouldNotSaveAfterLoad() { - when(index.getMeasure(Mockito.any(Resource.class), Mockito.any(Metric.class))) + when(index.getMeasure(Matchers.any(Resource.class), Matchers.any(Metric.class))) .thenReturn(new Measure("author").setData("1=simon;3=evgeny")); fileLineMeasures.getStringValue("author", 1); fileLineMeasures.save(); - verify(index, never()).addMeasure(Mockito.eq(resource), Mockito.any(Measure.class)); + verify(index, never()).addMeasure(Matchers.eq(resource), Matchers.any(Measure.class)); } @Test(expected = UnsupportedOperationException.class) public void shouldNotModifyAfterLoad() { - when(index.getMeasure(Mockito.any(Resource.class), Mockito.any(Metric.class))) + when(index.getMeasure(Matchers.any(Resource.class), Matchers.any(Metric.class))) .thenReturn(new Measure("author").setData("1=simon;3=evgeny")); fileLineMeasures.getStringValue("author", 1); diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java index 29b4c6e091d..cdb2eae7dd0 100644 --- a/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java +++ b/sonar-duplications/src/test/java/org/sonar/duplications/statement/StatementChannelTest.java @@ -26,12 +26,13 @@ import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; +import org.mockito.Matchers; + import java.util.Arrays; import java.util.List; import org.junit.Test; import org.mockito.ArgumentCaptor; -import org.mockito.Mockito; import org.sonar.duplications.statement.matcher.AnyTokenMatcher; import org.sonar.duplications.statement.matcher.TokenMatcher; import org.sonar.duplications.token.Token; @@ -58,7 +59,7 @@ public class StatementChannelTest { assertThat(channel.consume(tokenQueue, output), is(false)); ArgumentCaptor<List> matchedTokenList = ArgumentCaptor.forClass(List.class); - verify(matcher).matchToken(Mockito.eq(tokenQueue), matchedTokenList.capture()); + verify(matcher).matchToken(Matchers.eq(tokenQueue), matchedTokenList.capture()); verifyNoMoreInteractions(matcher); verify(tokenQueue).pushForward(matchedTokenList.getValue()); verifyNoMoreInteractions(tokenQueue); @@ -74,7 +75,7 @@ public class StatementChannelTest { List<Statement> output = mock(List.class); assertThat(channel.consume(tokenQueue, output), is(true)); - verify(matcher).matchToken(Mockito.eq(tokenQueue), Mockito.anyList()); + verify(matcher).matchToken(Matchers.eq(tokenQueue), Matchers.anyList()); verifyNoMoreInteractions(matcher); ArgumentCaptor<Statement> statement = ArgumentCaptor.forClass(Statement.class); verify(output).add(statement.capture()); @@ -92,9 +93,9 @@ public class StatementChannelTest { List<Statement> output = mock(List.class); assertThat(channel.consume(tokenQueue, output), is(true)); - verify(matcher).matchToken(Mockito.eq(tokenQueue), Mockito.anyList()); + verify(matcher).matchToken(Matchers.eq(tokenQueue), Matchers.anyList()); verifyNoMoreInteractions(matcher); - verify(output).add(Mockito.any(Statement.class)); + verify(output).add(Matchers.any(Statement.class)); verifyNoMoreInteractions(output); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java index b8972cc33d3..73091358c83 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/XMLRuleParser.java @@ -23,7 +23,6 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.CharEncoding; import org.apache.commons.lang.StringUtils; -import org.codehaus.stax2.XMLInputFactory2; import org.codehaus.staxmate.SMInputFactory; import org.codehaus.staxmate.in.SMHierarchicCursor; import org.codehaus.staxmate.in.SMInputCursor; @@ -75,7 +74,7 @@ public final class XMLRuleParser implements ServerComponent { } public List<Rule> parse(Reader reader) { - XMLInputFactory xmlFactory = XMLInputFactory2.newInstance(); + XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE); xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE); // just so it won't try to load DTD in if there's DOCTYPE diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java index 6ff7798de0f..783915b9c88 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java @@ -22,7 +22,6 @@ package org.sonar.api.utils; import com.ctc.wstx.stax.WstxInputFactory; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.stax2.XMLInputFactory2; import org.codehaus.staxmate.SMInputFactory; import org.codehaus.staxmate.in.SMHierarchicCursor; @@ -60,7 +59,7 @@ public class StaxParser { */ public StaxParser(XmlStreamHandler streamHandler, boolean isoControlCharsAwareParser) { this.streamHandler = streamHandler; - XMLInputFactory xmlFactory = XMLInputFactory2.newInstance(); + XMLInputFactory xmlFactory = XMLInputFactory.newInstance(); if (xmlFactory instanceof WstxInputFactory) { WstxInputFactory wstxInputfactory = (WstxInputFactory) xmlFactory; wstxInputfactory.configureForLowMemUsage(); diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenPluginTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenPluginTest.java index 9900353cb54..eaa1566e446 100644 --- a/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenPluginTest.java +++ b/sonar-plugin-api/src/test/java/org/sonar/api/batch/maven/MavenPluginTest.java @@ -25,8 +25,6 @@ import org.junit.Before; import org.junit.Test; import org.sonar.api.test.MavenTestUtils; -import java.util.Collection; - import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.Matchers.containsString; import static org.junit.Assert.assertThat; |