diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-01-28 22:41:25 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-02-10 17:16:01 +0100 |
commit | e9b5effe30cf68820a3dfb00bf736a325313206b (patch) | |
tree | 74323c9b304a2b5f76d2f77ca6c4b86d03fa4296 /plugins | |
parent | 46b6c6f692964e6202aa269245e579badb856e94 (diff) | |
download | sonarqube-e9b5effe30cf68820a3dfb00bf736a325313206b.tar.gz sonarqube-e9b5effe30cf68820a3dfb00bf736a325313206b.zip |
SONAR-6134, SONAR-6048 Improve performance of FS indexation
Diffstat (limited to 'plugins')
27 files changed, 81 insertions, 69 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java index d775ba8ec4c..61a6b69cc74 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecorator.java @@ -19,6 +19,9 @@ */ package org.sonar.plugins.core.issue; +import org.sonar.batch.components.TimeMachineConfiguration; + +import org.sonar.batch.deprecated.components.Period; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.*; import org.apache.commons.lang.time.DateUtils; @@ -32,8 +35,6 @@ import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.RulePriority; -import org.sonar.batch.components.Period; -import org.sonar.batch.components.TimeMachineConfiguration; import javax.annotation.Nullable; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java index 90435de8f3b..c275645899e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/AbstractNewCoverageFileAnalyzer.java @@ -19,8 +19,10 @@ */ package org.sonar.plugins.core.timemachine; -import org.sonar.api.batch.RequiresDB; +import org.sonar.batch.components.TimeMachineConfiguration; +import org.sonar.batch.deprecated.components.Period; +import org.sonar.api.batch.RequiresDB; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.lang.ObjectUtils; @@ -33,8 +35,6 @@ import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Resource; import org.sonar.api.resources.Scopes; import org.sonar.api.utils.KeyValueFormat; -import org.sonar.batch.components.Period; -import org.sonar.batch.components.TimeMachineConfiguration; import javax.annotation.Nullable; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java index ee415fdda33..352070ccc68 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageFileAnalyzer.java @@ -19,9 +19,10 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; -import org.sonar.batch.components.TimeMachineConfiguration; import java.util.List; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java index 61351c1a8e4..2dbcf8416a4 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewItCoverageFileAnalyzer.java @@ -19,9 +19,10 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; -import org.sonar.batch.components.TimeMachineConfiguration; public class NewItCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java index 6ff8481786e..b57db6dbe0e 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewOverallCoverageFileAnalyzer.java @@ -19,9 +19,10 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + import org.sonar.api.measures.CoreMetrics; import org.sonar.api.measures.Metric; -import org.sonar.batch.components.TimeMachineConfiguration; public class NewOverallCoverageFileAnalyzer extends AbstractNewCoverageFileAnalyzer { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java index 44684523efd..aa98cf6c603 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TendencyDecorator.java @@ -19,8 +19,9 @@ */ package org.sonar.plugins.core.timemachine; -import org.sonar.api.batch.RequiresDB; +import org.sonar.batch.deprecated.components.PeriodsDefinition; +import org.sonar.api.batch.RequiresDB; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ListMultimap; import com.google.common.collect.Lists; @@ -39,7 +40,6 @@ import org.sonar.api.measures.MetricFinder; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.resources.Scopes; -import org.sonar.batch.components.PeriodsDefinition; import java.util.List; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java index 84125404fb0..38083fed3db 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersister.java @@ -19,6 +19,9 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + +import org.sonar.batch.components.PastSnapshot; import org.sonar.api.batch.Decorator; import org.sonar.api.batch.DecoratorBarriers; import org.sonar.api.batch.DecoratorContext; @@ -28,8 +31,6 @@ import org.sonar.api.database.model.Snapshot; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.resources.ResourceUtils; -import org.sonar.batch.components.PastSnapshot; -import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.index.ResourceCache; import java.util.List; diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java index dc6cab324c7..a997423aa37 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/VariationDecorator.java @@ -19,6 +19,10 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + +import org.sonar.batch.components.PastSnapshot; +import org.sonar.batch.components.PastMeasuresLoader; import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; import org.sonar.api.batch.Decorator; @@ -38,9 +42,6 @@ import org.sonar.api.resources.Scopes; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.technicaldebt.batch.Characteristic; -import org.sonar.batch.components.PastMeasuresLoader; -import org.sonar.batch.components.PastSnapshot; -import org.sonar.batch.components.TimeMachineConfiguration; import javax.annotation.Nullable; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountFalsePositivesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountFalsePositivesDecoratorTest.java index cb8007f0b81..28327ac5954 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountFalsePositivesDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountFalsePositivesDecoratorTest.java @@ -34,7 +34,10 @@ import org.sonar.java.api.JavaClass; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyZeroInteractions; +import static org.mockito.Mockito.when; public class CountFalsePositivesDecoratorTest { @@ -48,7 +51,7 @@ public class CountFalsePositivesDecoratorTest { DefaultIssue fixed = new DefaultIssue().setRuleKey(RuleKey.parse("squid:AvoidCycles")) .setResolution(Issue.RESOLUTION_FIXED).setStatus(Issue.STATUS_RESOLVED); - File file = new File("foo.c"); + File file = File.create("foo.c"); Issuable issuable = mock(Issuable.class); when(perspectives.as(Issuable.class, file)).thenReturn(issuable); when(issuable.resolvedIssues()).thenReturn(Arrays.<Issue>asList(falsePositive, fixed)); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java index be9b8ae586c..912779a5356 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/CountUnresolvedIssuesDecoratorTest.java @@ -20,6 +20,9 @@ package org.sonar.plugins.core.issue; +import org.sonar.batch.components.TimeMachineConfiguration; + +import org.sonar.batch.deprecated.components.Period; import com.google.common.collect.Lists; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.time.DateUtils; @@ -40,8 +43,6 @@ import org.sonar.api.rule.Severity; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; import org.sonar.api.test.IsRuleMeasure; -import org.sonar.batch.components.Period; -import org.sonar.batch.components.TimeMachineConfiguration; import java.util.Calendar; import java.util.Collections; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java index adb52dfece0..01524877fb1 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/DirectoriesDecoratorTest.java @@ -43,7 +43,7 @@ public class DirectoriesDecoratorTest { @Test public void doNotInsertZeroOnFiles() { DirectoriesDecorator decorator = new DirectoriesDecorator(); - Resource file = new File("foo.php"); + Resource file = File.create("foo.php"); DecoratorContext context = mock(DecoratorContext.class); decorator.decorate(file, context); @@ -54,7 +54,7 @@ public class DirectoriesDecoratorTest { @Test public void directoryCountsForOne() { DirectoriesDecorator decorator = new DirectoriesDecorator(); - Resource directory = new Directory("org/foo"); + Resource directory = Directory.create("org/foo"); DecoratorContext context = mock(DecoratorContext.class); decorator.decorate(directory, context); verify(context).saveMeasure(CoreMetrics.DIRECTORIES, 1.0); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ManualMeasureDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ManualMeasureDecoratorTest.java index 2731680adc9..02793e1160c 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ManualMeasureDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/sensors/ManualMeasureDecoratorTest.java @@ -39,7 +39,7 @@ public class ManualMeasureDecoratorTest extends AbstractDbUnitTestCase { public void testCopyManualMeasures() throws Exception { setupData("testCopyManualMeasures"); - File javaFile = new File("Foo.java"); + File javaFile = File.create("Foo.java"); javaFile.setId(40); ManualMeasureDecorator decorator = new ManualMeasureDecorator(getSession(), new DefaultMetricFinder(getSessionFactory())); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java index ce7cc6cf5dd..839e6f51862 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TendencyDecoratorTest.java @@ -36,8 +36,8 @@ import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; -import static org.hamcrest.Matchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; import static org.mockito.Matchers.anyList; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; @@ -75,14 +75,14 @@ public class TendencyDecoratorTest { new Object[] {date("2009-12-02"), CoreMetrics.LINES, 1300.0}, new Object[] {date("2009-12-02"), CoreMetrics.COVERAGE, 79.6}, new Object[] {date("2009-12-15"), CoreMetrics.LINES, 1150.0} - )); + )); DecoratorContext context = mock(DecoratorContext.class); when(context.getMeasure(CoreMetrics.LINES)).thenReturn(new Measure(CoreMetrics.LINES, 1400.0)); when(context.getMeasure(CoreMetrics.COVERAGE)).thenReturn(new Measure(CoreMetrics.LINES, 90.0)); TendencyDecorator decorator = new TendencyDecorator(timeMachine, query, analyser); - decorator.decorate(new Directory("org/foo"), context); + decorator.decorate(Directory.create("org/foo"), context); verify(analyser).analyseLevel(Arrays.asList(1200.0, 1300.0, 1150.0, 1400.0)); verify(analyser).analyseLevel(Arrays.asList(80.5, 79.6, 90.0)); @@ -97,11 +97,11 @@ public class TendencyDecoratorTest { when(timeMachine.getMeasuresFields(query)).thenReturn(Arrays.<Object[]>asList( new Object[] {date("2009-12-01"), CoreMetrics.LINES, 1200.0}, new Object[] {date("2009-12-02"), CoreMetrics.LINES, 1300.0} - )); + )); DecoratorContext context = mock(DecoratorContext.class); TendencyDecorator decorator = new TendencyDecorator(timeMachine, query, analyser); - decorator.decorate(new Directory("org/foo"), context); + decorator.decorate(Directory.create("org/foo"), context); verify(analyser, never()).analyseLevel(anyList()); } diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java index f422f6f6020..ae79e7a47d3 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/TimeMachineConfigurationPersisterTest.java @@ -19,12 +19,13 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + +import org.sonar.batch.components.PastSnapshot; import org.junit.Test; import org.sonar.api.database.model.Snapshot; import org.sonar.api.resources.Project; import org.sonar.api.utils.DateUtils; -import org.sonar.batch.components.PastSnapshot; -import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.batch.index.ResourceCache; import org.sonar.jpa.test.AbstractDbUnitTestCase; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java index 4f6569e08cd..223abadcbac 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/timemachine/VariationDecoratorTest.java @@ -19,6 +19,10 @@ */ package org.sonar.plugins.core.timemachine; +import org.sonar.batch.components.TimeMachineConfiguration; + +import org.sonar.batch.components.PastSnapshot; +import org.sonar.batch.components.PastMeasuresLoader; import org.junit.Test; import org.mockito.Matchers; import org.sonar.api.batch.DecoratorContext; @@ -33,9 +37,6 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; -import org.sonar.batch.components.PastMeasuresLoader; -import org.sonar.batch.components.PastSnapshot; -import org.sonar.batch.components.TimeMachineConfiguration; import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.Arrays; @@ -64,12 +65,12 @@ public class VariationDecoratorTest extends AbstractDbUnitTestCase { VariationDecorator decorator = new VariationDecorator(mock(PastMeasuresLoader.class), mock(MetricFinder.class), timeMachineConfiguration, mock(RuleFinder.class)); assertThat(decorator.shouldComputeVariation(new Project("foo"))).isTrue(); - assertThat(decorator.shouldComputeVariation(new File("foo/bar.c"))).isFalse(); + assertThat(decorator.shouldComputeVariation(File.create("foo/bar.c"))).isFalse(); } @Test public void shouldCompareAndSaveVariation() { - Resource dir = new Directory("org/foo"); + Resource dir = Directory.create("org/foo"); PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class); PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1); @@ -117,7 +118,7 @@ public class VariationDecoratorTest extends AbstractDbUnitTestCase { when(ruleFinder.findByKey(rule1.ruleKey())).thenReturn(rule1); when(ruleFinder.findByKey(rule2.ruleKey())).thenReturn(rule2); - Resource dir = new Directory("org/foo"); + Resource dir = Directory.create("org/foo"); PastMeasuresLoader pastMeasuresLoader = mock(PastMeasuresLoader.class); PastSnapshot pastSnapshot1 = new PastSnapshot("days", new Date()).setIndex(1); diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java index 28a78f5cc50..a4cfc381ae8 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/CpdSensorTest.java @@ -52,7 +52,7 @@ public class CpdSensorTest { sonarBridgeEngine = new DefaultCpdEngine(indexFactory, new CpdMappings(), null, null, mock(BlockCache.class)); settings = new Settings(new PropertyDefinitions(CpdPlugin.class)); - DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder()); + DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder().toPath()); sensor = new CpdSensor(sonarEngine, sonarBridgeEngine, settings, fs); } diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/JavaCpdEngineTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/JavaCpdEngineTest.java index aa87b90dc13..182f57091d0 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/JavaCpdEngineTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/JavaCpdEngineTest.java @@ -72,7 +72,7 @@ public class JavaCpdEngineTest { inputFile = new DeprecatedDefaultInputFile("foo", "src/main/java/Foo.java"); duplicationBuilder = spy(new DefaultDuplicationBuilder(inputFile)); when(context.duplicationBuilder(any(InputFile.class))).thenReturn(duplicationBuilder); - inputFile.setFile(temp.newFile("Foo.java")); + inputFile.setModuleBaseDir(temp.newFolder().toPath()); } @SuppressWarnings("unchecked") diff --git a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java index 0c733e9227a..de90865b0d0 100644 --- a/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java +++ b/plugins/sonar-cpd-plugin/src/test/java/org/sonar/plugins/cpd/decorators/SumDuplicationsDecoratorTest.java @@ -27,8 +27,8 @@ import org.sonar.api.resources.File; import org.sonar.api.resources.Qualifiers; import org.sonar.api.test.IsMeasure; -import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.argThat; @@ -48,7 +48,7 @@ public class SumDuplicationsDecoratorTest { @Test public void doNotSetDuplicationsOnUnitTests() { SumDuplicationsDecorator decorator = new SumDuplicationsDecorator(); - File unitTest = new File("org/foo/BarTest.java"); + File unitTest = File.create("org/foo/BarTest.java"); unitTest.setQualifier(Qualifiers.UNIT_TEST_FILE); DecoratorContext context = mock(DecoratorContext.class); @@ -60,7 +60,7 @@ public class SumDuplicationsDecoratorTest { @Test public void saveZeroIfNoDuplications() { SumDuplicationsDecorator decorator = new SumDuplicationsDecorator(); - File file = new File("org/foo/BarTest.java"); + File file = File.create("org/foo/BarTest.java"); DecoratorContext context = mock(DecoratorContext.class); decorator.decorate(file, context); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java index 7cf94a15d02..4b57e397362 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/CoveragePerTestSensorTest.java @@ -57,7 +57,7 @@ public class CoveragePerTestSensorTest { public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new CoveragePerTestSensor(); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); } @@ -68,7 +68,7 @@ public class CoveragePerTestSensorTest { @Test public void testNoExecutionIfCoveragePerTestFile() { - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setAbsolutePath(new File(baseDir, "test/fooTest.xoo").getAbsolutePath()).setLanguage("xoo") + DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") .setType(Type.TEST); fileSystem.add(testFile); sensor.execute(context); @@ -78,8 +78,8 @@ public class CoveragePerTestSensorTest { public void testExecution() throws IOException { File coverPerTest = new File(baseDir, "test/fooTest.xoo.coveragePerTest"); FileUtils.write(coverPerTest, "test1:src/foo.xoo:1,2,3,4\ntest2:src/foo.xoo:5,6,7\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setAbsolutePath(new File(baseDir, "test/fooTest.xoo").getAbsolutePath()).setLanguage("xoo") + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") .setType(Type.TEST); fileSystem.add(inputFile); fileSystem.add(testFile); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java index 46f6e56c69d..e586263feda 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/DependencySensorTest.java @@ -56,7 +56,7 @@ public class DependencySensorTest { public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new DependencySensor(); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); } @@ -67,7 +67,7 @@ public class DependencySensorTest { @Test public void testNoExecutionIfNoDepsFile() { - DefaultInputFile file = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo") + DefaultInputFile file = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo") .setType(Type.MAIN); fileSystem.add(file); sensor.execute(context); @@ -77,9 +77,9 @@ public class DependencySensorTest { public void testExecution() throws IOException { File deps = new File(baseDir, "src/foo.xoo.deps"); FileUtils.write(deps, "src/foo2.xoo:2\nsrc2/foo3.xoo:6\n\n#comment"); - DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); - DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/foo2.xoo").setAbsolutePath(new File(baseDir, "src/foo2.xoo").getAbsolutePath()).setLanguage("xoo"); - DefaultInputFile inputFile3 = new DefaultInputFile("foo", "src2/foo3.xoo").setAbsolutePath(new File(baseDir, "src2/foo3.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile1 = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); + DefaultInputFile inputFile2 = new DefaultInputFile("foo", "src/foo2.xoo").setLanguage("xoo"); + DefaultInputFile inputFile3 = new DefaultInputFile("foo", "src2/foo3.xoo").setLanguage("xoo"); fileSystem.add(inputFile1); fileSystem.add(inputFile2); fileSystem.add(inputFile3); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java index ade948848f7..6626a5e9545 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/MeasureSensorTest.java @@ -65,7 +65,7 @@ public class MeasureSensorTest { baseDir = temp.newFolder(); metricFinder = mock(MetricFinder.class); sensor = new MeasureSensor(metricFinder); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); storage = mock(SensorStorage.class); when(context.newMeasure()).then(new Answer<DefaultMeasure>() { @@ -83,7 +83,7 @@ public class MeasureSensorTest { @Test public void testNoExecutionIfNoMeasureFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); sensor.execute(context); } @@ -92,7 +92,7 @@ public class MeasureSensorTest { public void testExecution() throws IOException { File measures = new File(baseDir, "src/foo.xoo.measures"); FileUtils.write(measures, "ncloc:12\nbranch_coverage:5.3\nsqale_index:300\nbool:true\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); Metric<Boolean> booleanMetric = new Metric.Builder("bool", "Bool", Metric.ValueType.BOOL) @@ -115,7 +115,7 @@ public class MeasureSensorTest { public void failIfMetricNotFound() throws IOException { File measures = new File(baseDir, "src/foo.xoo.measures"); FileUtils.write(measures, "unknow:12\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); thrown.expect(IllegalStateException.class); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java index 945253e72b0..5673221a46e 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SymbolReferencesSensorTest.java @@ -52,7 +52,7 @@ public class SymbolReferencesSensorTest { public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new SymbolReferencesSensor(); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); } @@ -63,7 +63,7 @@ public class SymbolReferencesSensorTest { @Test public void testNoExecutionIfNoSymbolFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); sensor.execute(context); } @@ -72,7 +72,7 @@ public class SymbolReferencesSensorTest { public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.symbol"); FileUtils.write(symbol, "1,4,7\n12,15,23\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); SymbolTableBuilder symbolTableBuilder = mock(SymbolTableBuilder.class); when(context.symbolTableBuilder(inputFile)).thenReturn(symbolTableBuilder); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java index 75c5a1c6685..559f6b37b08 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/SyntaxHighlightingSensorTest.java @@ -52,7 +52,7 @@ public class SyntaxHighlightingSensorTest { public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new SyntaxHighlightingSensor(); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); } @@ -63,7 +63,7 @@ public class SyntaxHighlightingSensorTest { @Test public void testNoExecutionIfNoSyntaxFile() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); sensor.execute(context); } @@ -72,7 +72,7 @@ public class SyntaxHighlightingSensorTest { public void testExecution() throws IOException { File symbol = new File(baseDir, "src/foo.xoo.highlighting"); FileUtils.write(symbol, "1:4:k\n12:15:cppd\n\n#comment"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); HighlightingBuilder builder = mock(HighlightingBuilder.class); when(context.highlightingBuilder(inputFile)).thenReturn(builder); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java index 41109c800c4..5e1a1344f4e 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/TestCaseSensorTest.java @@ -56,7 +56,7 @@ public class TestCaseSensorTest { public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new TestCaseSensor(); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); } @@ -67,7 +67,7 @@ public class TestCaseSensorTest { @Test public void testNoExecutionIfNoTestFile() { - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setAbsolutePath(new File(baseDir, "test/fooTest.xoo").getAbsolutePath()).setLanguage("xoo") + DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") .setType(Type.TEST); fileSystem.add(testFile); sensor.execute(context); @@ -77,7 +77,7 @@ public class TestCaseSensorTest { public void testExecution() throws IOException { File testPlan = new File(baseDir, "test/fooTest.xoo.testplan"); FileUtils.write(testPlan, "test1:UNIT:OK:::10\ntest2:INTEGRATION:ERROR:message:stack:15\n\n#comment"); - DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setAbsolutePath(new File(baseDir, "test/fooTest.xoo").getAbsolutePath()).setLanguage("xoo") + DefaultInputFile testFile = new DefaultInputFile("foo", "test/fooTest.xoo").setLanguage("xoo") .setType(Type.TEST); fileSystem.add(testFile); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerSensorTest.java index 752f4144aba..1fe44615f9b 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/lang/XooTokenizerSensorTest.java @@ -57,7 +57,7 @@ public class XooTokenizerSensorTest { public void prepare() throws IOException { baseDir = temp.newFolder(); sensor = new XooTokenizerSensor(); - fileSystem = new DefaultFileSystem(baseDir); + fileSystem = new DefaultFileSystem(baseDir.toPath()); when(context.fileSystem()).thenReturn(fileSystem); settings = new Settings(); when(context.settings()).thenReturn(settings); @@ -70,7 +70,7 @@ public class XooTokenizerSensorTest { @Test public void testNoExecutionIfExclusion() { - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); settings.setProperty(CoreProperties.CPD_EXCLUSIONS, "**/foo.xoo"); sensor.execute(context); @@ -81,7 +81,7 @@ public class XooTokenizerSensorTest { public void testExecution() throws IOException { File source = new File(baseDir, "src/foo.xoo"); FileUtils.write(source, "token1 token2 token3\ntoken4"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo"); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage("xoo"); fileSystem.add(inputFile); DuplicationTokenBuilder builder = mock(DuplicationTokenBuilder.class); when(context.duplicationTokenBuilder(inputFile)).thenReturn(builder); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java index f283ffb0cd1..9f1a4436a0e 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/rule/OneIssuePerLineSensorTest.java @@ -60,7 +60,7 @@ public class OneIssuePerLineSensorTest { @Test public void testRule() throws IOException { - DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder()); + DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder().toPath()); DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).setLines(10); fs.add(inputFile); @@ -84,7 +84,7 @@ public class OneIssuePerLineSensorTest { @Test public void testForceSeverity() throws IOException { - DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder()); + DefaultFileSystem fs = new DefaultFileSystem(temp.newFolder().toPath()); DefaultInputFile inputFile = new DefaultInputFile("foo", "src/Foo.xoo").setLanguage(Xoo.KEY).setLines(10); fs.add(inputFile); diff --git a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java index d0156cc083d..eda682a7a43 100644 --- a/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java +++ b/plugins/sonar-xoo-plugin/src/test/java/org/sonar/xoo/scm/XooBlameCommandTest.java @@ -57,7 +57,7 @@ public class XooBlameCommandTest { @Before public void prepare() throws IOException { baseDir = temp.newFolder(); - fs = new DefaultFileSystem(baseDir); + fs = new DefaultFileSystem(baseDir.toPath()); input = mock(BlameInput.class); when(input.fileSystem()).thenReturn(fs); } @@ -68,7 +68,7 @@ public class XooBlameCommandTest { FileUtils.write(source, "sample content"); File scm = new File(baseDir, "src/foo.xoo.scm"); FileUtils.write(scm, "123,julien,2014-12-12\n234,julien,2014-12-24"); - DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage(Xoo.KEY); + DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setLanguage(Xoo.KEY); fs.add(inputFile); BlameOutput result = mock(BlameOutput.class); |