aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorJulien HENRY <henryju@yahoo.fr>2016-07-04 11:58:10 +0200
committerJulien HENRY <henryju@yahoo.fr>2016-07-05 14:00:16 +0200
commit103f9ca40fe6c4864aa489119c1590e0449f1b9f (patch)
treea990c8be0e88b324307c2e3163559a42b1cfa0ac /sonar-scanner-engine
parentb7fcb4dd974df546cc13faa6be6529ca6bc26688 (diff)
downloadsonarqube-103f9ca40fe6c4864aa489119c1590e0449f1b9f.tar.gz
sonarqube-103f9ca40fe6c4864aa489119c1590e0449f1b9f.zip
SONAR-7727 Remove deprecated stuff from Resources API
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/ProjectConfigurator.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java19
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/phases/AbstractPhaseExecutor.java7
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/phases/IssuesPhaseExecutor.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/phases/ProjectInitializer.java63
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/phases/PublishPhaseExecutor.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java2
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/FakeJava.java38
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java19
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java10
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java8
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java6
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java8
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java4
15 files changed, 64 insertions, 137 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/ProjectConfigurator.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/ProjectConfigurator.java
index aee2aab3d71..a0b55e50519 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/ProjectConfigurator.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/ProjectConfigurator.java
@@ -21,8 +21,6 @@ package org.sonar.batch;
import java.util.Date;
import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
import org.sonar.api.batch.ScannerSide;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
@@ -38,7 +36,6 @@ import org.sonar.api.utils.System2;
@ScannerSide
public class ProjectConfigurator {
- private static final Logger LOG = LoggerFactory.getLogger(ProjectConfigurator.class);
private final System2 system2;
private Settings settings;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java
index d816ae0dd85..2831159d8dd 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/index/DefaultIndex.java
@@ -312,25 +312,6 @@ public class DefaultIndex {
relativePathFromSourceDir = "";
}
}
- if (relativePathFromSourceDir != null) {
- // Resolve using deprecated key
- List<String> dirs;
- ProjectDefinition projectDef = projectTree.getProjectDefinition(getProject());
- if (isTest) {
- dirs = projectDef.tests();
- } else {
- dirs = projectDef.sources();
- }
- for (String src : dirs) {
- java.io.File dirOrFile = pathResolver.relativeFile(projectDef.getBaseDir(), src);
- java.io.File abs = new java.io.File(dirOrFile, relativePathFromSourceDir);
- Bucket b = getBucket(isDir ? Directory.fromIOFile(abs, getProject()) : File.fromIOFile(abs, getProject()));
- if (b != null) {
- return b;
- }
- }
-
- }
return null;
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/AbstractPhaseExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/AbstractPhaseExecutor.java
index c388b75f1f3..d3265de0aac 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/AbstractPhaseExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/AbstractPhaseExecutor.java
@@ -37,7 +37,6 @@ public abstract class AbstractPhaseExecutor {
private final SensorsExecutor sensorsExecutor;
private final SensorContext sensorContext;
private final DefaultIndex index;
- private final ProjectInitializer pi;
private final FileSystemLogger fsLogger;
private final DefaultModuleFileSystem fs;
private final QProfileVerifier profileVerifier;
@@ -45,8 +44,7 @@ public abstract class AbstractPhaseExecutor {
public AbstractPhaseExecutor(InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor,
SensorContext sensorContext, DefaultIndex index,
- EventBus eventBus, ProjectInitializer pi,
- FileSystemLogger fsLogger, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
+ EventBus eventBus, FileSystemLogger fsLogger, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
IssueExclusionsLoader issueExclusionsLoader) {
this.postJobsExecutor = postJobsExecutor;
this.initializersExecutor = initializersExecutor;
@@ -54,7 +52,6 @@ public abstract class AbstractPhaseExecutor {
this.sensorContext = sensorContext;
this.index = index;
this.eventBus = eventBus;
- this.pi = pi;
this.fsLogger = fsLogger;
this.fs = fs;
this.profileVerifier = profileVerifier;
@@ -65,8 +62,6 @@ public abstract class AbstractPhaseExecutor {
* Executed on each module
*/
public final void execute(Project module) {
- pi.execute(module);
-
eventBus.fireEvent(new ProjectAnalysisEvent(module, true));
executeInitializersPhase();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/IssuesPhaseExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/IssuesPhaseExecutor.java
index ba9a155962e..5d8a658e52f 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/IssuesPhaseExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/IssuesPhaseExecutor.java
@@ -43,9 +43,9 @@ public final class IssuesPhaseExecutor extends AbstractPhaseExecutor {
private final IssueCallback issueCallback;
public IssuesPhaseExecutor(InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, SensorContext sensorContext,
- DefaultIndex index, EventBus eventBus, ProjectInitializer pi, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
+ DefaultIndex index, EventBus eventBus, FileSystemLogger fsLogger, IssuesReports jsonReport, DefaultModuleFileSystem fs, QProfileVerifier profileVerifier,
IssueExclusionsLoader issueExclusionsLoader, IssueTransition localIssueTracking, IssueCallback issueCallback) {
- super(initializersExecutor, postJobsExecutor, sensorsExecutor, sensorContext, index, eventBus, pi, fsLogger, fs, profileVerifier, issueExclusionsLoader);
+ super(initializersExecutor, postJobsExecutor, sensorsExecutor, sensorContext, index, eventBus, fsLogger, fs, profileVerifier, issueExclusionsLoader);
this.eventBus = eventBus;
this.issuesReport = jsonReport;
this.localIssueTracking = localIssueTracking;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/ProjectInitializer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
deleted file mode 100644
index b9a4b45ff8a..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/ProjectInitializer.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.batch.phases;
-
-import org.sonar.api.batch.ScannerSide;
-import org.apache.commons.lang.StringUtils;
-import org.sonar.api.CoreProperties;
-import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Language;
-import org.sonar.api.resources.Languages;
-import org.sonar.api.resources.Project;
-import org.sonar.api.utils.MessageException;
-
-/**
- * Should be dropped when org.sonar.api.resources.Project is fully refactored.
- */
-@ScannerSide
-public class ProjectInitializer {
-
- private Languages languages;
- private Settings settings;
-
- public ProjectInitializer(Settings settings, Languages languages) {
- this.settings = settings;
- this.languages = languages;
- }
-
- public void execute(Project project) {
- if (project.getLanguage() == null) {
- initDeprecatedLanguage(project);
- }
- }
-
- private void initDeprecatedLanguage(Project project) {
- String languageKey = settings.getString(CoreProperties.PROJECT_LANGUAGE_PROPERTY);
- if (StringUtils.isNotBlank(languageKey)) {
- Language language = languages.get(languageKey);
- if (language == null) {
- throw MessageException.of("Language with key '" + languageKey + "' not found");
- }
- project.setLanguage(language);
- } else {
- project.setLanguage(Project.NONE_LANGUAGE);
- }
- }
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/PublishPhaseExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/PublishPhaseExecutor.java
index 33073a110b3..98741b5aaf9 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/PublishPhaseExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/phases/PublishPhaseExecutor.java
@@ -37,9 +37,9 @@ public final class PublishPhaseExecutor extends AbstractPhaseExecutor {
private final CpdExecutor cpdExecutor;
public PublishPhaseExecutor(InitializersExecutor initializersExecutor, PostJobsExecutor postJobsExecutor, SensorsExecutor sensorsExecutor, SensorContext sensorContext,
- DefaultIndex index, EventBus eventBus, ReportPublisher reportPublisher, ProjectInitializer pi, FileSystemLogger fsLogger, DefaultModuleFileSystem fs,
+ DefaultIndex index, EventBus eventBus, ReportPublisher reportPublisher, FileSystemLogger fsLogger, DefaultModuleFileSystem fs,
QProfileVerifier profileVerifier, IssueExclusionsLoader issueExclusionsLoader, CpdExecutor cpdExecutor) {
- super(initializersExecutor, postJobsExecutor, sensorsExecutor, sensorContext, index, eventBus, pi, fsLogger, fs, profileVerifier, issueExclusionsLoader);
+ super(initializersExecutor, postJobsExecutor, sensorsExecutor, sensorContext, index, eventBus, fsLogger, fs, profileVerifier, issueExclusionsLoader);
this.eventBus = eventBus;
this.reportPublisher = reportPublisher;
this.cpdExecutor = cpdExecutor;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
index 2da9c9e4967..bca62d8b8f3 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java
@@ -52,7 +52,6 @@ import org.sonar.batch.phases.AbstractPhaseExecutor;
import org.sonar.batch.phases.InitializersExecutor;
import org.sonar.batch.phases.IssuesPhaseExecutor;
import org.sonar.batch.phases.PostJobsExecutor;
-import org.sonar.batch.phases.ProjectInitializer;
import org.sonar.batch.phases.PublishPhaseExecutor;
import org.sonar.batch.phases.SensorsExecutor;
import org.sonar.batch.postjob.DefaultPostJobContext;
@@ -120,7 +119,6 @@ public class ModuleScanContainer extends ComponentContainer {
PostJobsExecutor.class,
SensorsExecutor.class,
InitializersExecutor.class,
- ProjectInitializer.class,
// file system
ModuleInputFileCache.class,
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/FakeJava.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/FakeJava.java
new file mode 100644
index 00000000000..95c2244ab54
--- /dev/null
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/FakeJava.java
@@ -0,0 +1,38 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.batch;
+
+import org.sonar.api.resources.AbstractLanguage;
+
+public class FakeJava extends AbstractLanguage {
+
+ public static final String KEY = "java";
+ public static final FakeJava INSTANCE = new FakeJava();
+
+ public FakeJava() {
+ super(KEY, "Java");
+ }
+
+ @Override
+ public String[] getFileSuffixes() {
+ return new String[] {".java", ".jav"};
+ }
+
+}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
index 84b725007d8..7a4d248ca21 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/ProjectConfiguratorTest.java
@@ -81,23 +81,4 @@ public class ProjectConfiguratorTest {
new ProjectConfigurator(configuration, system2).configure(project);
}
- @Test
- public void default_analysis_type_is_dynamic() {
- Project project = new Project("key");
- new ProjectConfigurator(new Settings(), system2).configure(project);
- assertThat(project.getAnalysisType()).isEqualTo(Project.AnalysisType.DYNAMIC);
- }
-
- @Test
- public void is_dynamic_analysis() {
- assertThat(Project.AnalysisType.DYNAMIC.isDynamic(false)).isTrue();
- assertThat(Project.AnalysisType.DYNAMIC.isDynamic(true)).isTrue();
-
- assertThat(Project.AnalysisType.STATIC.isDynamic(false)).isFalse();
- assertThat(Project.AnalysisType.STATIC.isDynamic(true)).isFalse();
-
- assertThat(Project.AnalysisType.REUSE_REPORTS.isDynamic(false)).isFalse();
- assertThat(Project.AnalysisType.REUSE_REPORTS.isDynamic(true)).isTrue();
- }
-
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java
index 4adc630247e..b9f53ef7603 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/cpd/deprecated/DeprecatedCpdBlockIndexerSensorTest.java
@@ -27,7 +27,7 @@ import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
+import org.sonar.batch.FakeJava;
import org.sonar.batch.cpd.CpdComponents;
import static org.assertj.core.api.Assertions.assertThat;
@@ -55,12 +55,12 @@ public class DeprecatedCpdBlockIndexerSensorTest {
@Test
public void test_global_skip() {
settings.setProperty("sonar.cpd.skip", true);
- assertThat(sensor.isSkipped(Java.KEY)).isTrue();
+ assertThat(sensor.isSkipped(FakeJava.KEY)).isTrue();
}
@Test
public void should_not_skip_by_default() {
- assertThat(sensor.isSkipped(Java.KEY)).isFalse();
+ assertThat(sensor.isSkipped(FakeJava.KEY)).isFalse();
}
@Test
@@ -69,12 +69,12 @@ public class DeprecatedCpdBlockIndexerSensorTest {
settings.setProperty("sonar.cpd.php.skip", true);
assertThat(sensor.isSkipped("php")).isTrue();
- assertThat(sensor.isSkipped(Java.KEY)).isFalse();
+ assertThat(sensor.isSkipped(FakeJava.KEY)).isFalse();
}
@Test
public void test_engine() {
- assertThat(sensor.getBlockIndexer(Java.KEY)).isSameAs(sonarEngine);
+ assertThat(sensor.getBlockIndexer(FakeJava.KEY)).isSameAs(sonarEngine);
assertThat(sensor.getBlockIndexer("PHP")).isSameAs(sonarBridgeEngine);
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
index 8dae9e19ad0..71d560b3d70 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/index/DefaultIndexTest.java
@@ -30,13 +30,13 @@ import org.sonar.api.measures.MeasuresFilters;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.resources.Directory;
import org.sonar.api.resources.File;
-import org.sonar.api.resources.Java;
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.api.scan.filesystem.PathResolver;
import org.sonar.batch.DefaultProjectTree;
+import org.sonar.batch.FakeJava;
import org.sonar.batch.scan.measure.MeasureCache;
import org.sonar.batch.sensor.DefaultSensorStorage;
@@ -101,7 +101,7 @@ public class DefaultIndexTest {
@Test
public void shouldIndexTreeOfResources() {
Directory directory = Directory.create("src/org/foo");
- File file = File.create("src/org/foo/Bar.java", Java.INSTANCE, false);
+ File file = File.create("src/org/foo/Bar.java", FakeJava.INSTANCE, false);
assertThat(index.index(directory)).isTrue();
assertThat(index.index(file, directory)).isTrue();
@@ -118,7 +118,7 @@ public class DefaultIndexTest {
@Test
public void shouldGetSource() throws Exception {
Directory directory = Directory.create("src/org/foo");
- File file = File.create("src/org/foo/Bar.java", Java.INSTANCE, false);
+ File file = File.create("src/org/foo/Bar.java", FakeJava.INSTANCE, false);
FileUtils.write(new java.io.File(baseDir, "src/org/foo/Bar.java"), "Foo bar");
assertThat(index.index(directory)).isTrue();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
index 65c54c6f5c6..d2260c3e070 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/report/ComponentsPublisherTest.java
@@ -29,9 +29,9 @@ import org.sonar.api.batch.fs.internal.DefaultInputDir;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.fs.internal.DefaultInputModule;
import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.Java;
import org.sonar.api.resources.Project;
import org.sonar.api.utils.DateUtils;
+import org.sonar.batch.FakeJava;
import org.sonar.batch.index.BatchComponentCache;
import org.sonar.batch.scan.ImmutableProjectReactor;
import org.sonar.scanner.protocol.output.FileStructure;
@@ -70,7 +70,7 @@ public class ComponentsPublisherTest {
dir.setId(3).setUuid("DIR_UUID");
resourceCache.add(dir, module1).setInputComponent(new DefaultInputDir("foo", "src"));
- org.sonar.api.resources.File file = org.sonar.api.resources.File.create("src/Foo.java", Java.INSTANCE, false);
+ org.sonar.api.resources.File file = org.sonar.api.resources.File.create("src/Foo.java", FakeJava.INSTANCE, false);
file.setEffectiveKey("module1:src/Foo.java");
file.setId(4).setUuid("FILE_UUID");
resourceCache.add(file, dir).setInputComponent(new DefaultInputFile("module1", "src/Foo.java").setLines(2));
@@ -80,7 +80,7 @@ public class ComponentsPublisherTest {
fileWithoutLang.setId(5).setUuid("FILE_WITHOUT_LANG_UUID");
resourceCache.add(fileWithoutLang, dir).setInputComponent(new DefaultInputFile("module1", "src/make").setLines(10));
- org.sonar.api.resources.File testFile = org.sonar.api.resources.File.create("test/FooTest.java", Java.INSTANCE, true);
+ org.sonar.api.resources.File testFile = org.sonar.api.resources.File.create("test/FooTest.java", FakeJava.INSTANCE, true);
testFile.setEffectiveKey("module1:test/FooTest.java");
testFile.setId(6).setUuid("TEST_FILE_UUID");
resourceCache.add(testFile, dir).setInputComponent(new DefaultInputFile("module1", "test/FooTest.java").setLines(4));
@@ -141,7 +141,7 @@ public class ComponentsPublisherTest {
dir.setId(3).setUuid("DIR_UUID");
resourceCache.add(dir, module1).setInputComponent(new DefaultInputDir("foo", "src"));
- org.sonar.api.resources.File file = org.sonar.api.resources.File.create("src/Foo.java", Java.INSTANCE, false);
+ org.sonar.api.resources.File file = org.sonar.api.resources.File.create("src/Foo.java", FakeJava.INSTANCE, false);
file.setEffectiveKey("module1:my_branch:my_branch:src/Foo.java");
file.setId(4).setUuid("FILE_UUID");
resourceCache.add(file, dir).setInputComponent(new DefaultInputFile("module1", "src/Foo.java").setLines(2));
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java
index 22a4f21091f..55d8264b3ef 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/LanguageVerifierTest.java
@@ -26,9 +26,9 @@ import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
import org.sonar.api.resources.Languages;
import org.sonar.api.utils.MessageException;
+import org.sonar.batch.FakeJava;
import org.sonar.batch.repository.language.DefaultLanguagesRepository;
import org.sonar.batch.repository.language.LanguagesRepository;
@@ -43,7 +43,7 @@ public class LanguageVerifierTest {
public ExpectedException thrown = ExpectedException.none();
private Settings settings = new Settings();
- private LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(Java.INSTANCE));
+ private LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(FakeJava.INSTANCE));
private DefaultFileSystem fs;
@Before
@@ -61,7 +61,7 @@ public class LanguageVerifierTest {
verifier.stop();
}
-
+
@Test
public void language_is_empty() {
settings.setProperty("sonar.language", "");
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
index 8f5459ec40a..01228186217 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/ComponentIndexerTest.java
@@ -33,11 +33,11 @@ import org.sonar.api.batch.fs.internal.DefaultFileSystem;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.resources.AbstractLanguage;
import org.sonar.api.resources.Directory;
-import org.sonar.api.resources.Java;
import org.sonar.api.resources.Languages;
import org.sonar.api.resources.Project;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
+import org.sonar.batch.FakeJava;
import org.sonar.batch.analysis.DefaultAnalysisMode;
import org.sonar.batch.index.BatchComponent;
import org.sonar.batch.index.BatchComponentCache;
@@ -81,7 +81,7 @@ public class ComponentIndexerTest {
@Test
public void should_index_java_files() throws IOException {
- Languages languages = new Languages(Java.INSTANCE);
+ Languages languages = new Languages(FakeJava.INSTANCE);
ComponentIndexer indexer = createIndexer(languages);
DefaultModuleFileSystem fs = new DefaultModuleFileSystem(project, null, mock(FileIndexer.class), initializer, indexer, mode);
fs.add(newInputFile("src/main/java/foo/bar/Foo.java", "", "foo/bar/Foo.java", "java", false, Status.ADDED));
@@ -91,8 +91,8 @@ public class ComponentIndexerTest {
fs.index();
- verify(sonarIndex).index(org.sonar.api.resources.File.create("src/main/java/foo/bar/Foo.java", Java.INSTANCE, false));
- verify(sonarIndex).index(org.sonar.api.resources.File.create("src/main/java2/foo/bar/Foo.java", Java.INSTANCE, false));
+ verify(sonarIndex).index(org.sonar.api.resources.File.create("src/main/java/foo/bar/Foo.java", FakeJava.INSTANCE, false));
+ verify(sonarIndex).index(org.sonar.api.resources.File.create("src/main/java2/foo/bar/Foo.java", FakeJava.INSTANCE, false));
verify(sonarIndex).index(argThat(new ArgumentMatcher<org.sonar.api.resources.File>() {
@Override
public boolean matches(Object arg0) {
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java
index b30bb73036c..2f7d3f01434 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/batch/scan/filesystem/LanguageDetectionFactoryTest.java
@@ -21,8 +21,8 @@ package org.sonar.batch.scan.filesystem;
import org.junit.Test;
import org.sonar.api.config.Settings;
-import org.sonar.api.resources.Java;
import org.sonar.api.resources.Languages;
+import org.sonar.batch.FakeJava;
import org.sonar.batch.repository.language.DefaultLanguagesRepository;
import org.sonar.batch.repository.language.LanguagesRepository;
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
public class LanguageDetectionFactoryTest {
@Test
public void testCreate() throws Exception {
- LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(Java.INSTANCE));
+ LanguagesRepository languages = new DefaultLanguagesRepository(new Languages(FakeJava.INSTANCE));
LanguageDetectionFactory factory = new LanguageDetectionFactory(new Settings(), languages);
LanguageDetection languageDetection = factory.create();
assertThat(languageDetection).isNotNull();