aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch/src/test
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-01-15 23:50:31 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-01-15 23:50:31 +0100
commit445ac3e5a16c86d8906e82567657fefdb30d50e1 (patch)
treeb14ed1fb5a050b7d3890374b14a629ae77f463e5 /sonar-batch/src/test
parenta42dd4d2b9d0eafe67bd514d56f0ab4ffc8ddbea (diff)
downloadsonarqube-445ac3e5a16c86d8906e82567657fefdb30d50e1.tar.gz
sonarqube-445ac3e5a16c86d8906e82567657fefdb30d50e1.zip
SONAR-5077 Add option to import all files even if no language
Diffstat (limited to 'sonar-batch/src/test')
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java27
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java3
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java11
3 files changed, 33 insertions, 8 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
index 9dd41b52076..893bc1a132a 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/fs/FileSystemMediumTest.java
@@ -19,8 +19,6 @@
*/
package org.sonar.batch.mediumtest.fs;
-import org.sonar.batch.mediumtest.TaskResult;
-
import com.google.common.collect.ImmutableMap;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
@@ -34,6 +32,7 @@ import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
import org.sonar.batch.mediumtest.BatchMediumTester;
+import org.sonar.batch.mediumtest.TaskResult;
import org.sonar.xoo.XooPlugin;
import java.io.File;
@@ -205,4 +204,28 @@ public class FileSystemMediumTest {
}
}
+ @Test
+ public void indexAnyFile() throws IOException {
+ File srcDir = new File(baseDir, "src");
+ srcDir.mkdir();
+
+ File xooFile = new File(srcDir, "sample.xoo");
+ FileUtils.write(xooFile, "Sample xoo\ncontent");
+
+ File otherFile = new File(srcDir, "sample.other");
+ FileUtils.write(otherFile, "Sample other\ncontent");
+
+ TaskResult result = tester.newTask()
+ .properties(builder
+ .put("sonar.sources", "src")
+ .put("sonar.index_all_files", "true")
+ .build())
+ .start();
+
+ assertThat(result.inputFiles()).hasSize(2);
+ assertThat(result.inputFile("src/sample.other").type()).isEqualTo(InputFile.Type.MAIN);
+ assertThat(result.inputFile("src/sample.other").relativePath()).isEqualTo("src/sample.other");
+ assertThat(result.inputFile("src/sample.other").language()).isNull();
+ }
+
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
index 48941e1e208..9a753c7e66f 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderFactoryTest.java
@@ -22,6 +22,7 @@ package org.sonar.batch.scan.filesystem;
import org.junit.Test;
import org.mockito.Mockito;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
+import org.sonar.api.config.Settings;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.batch.bootstrap.AnalysisMode;
@@ -38,7 +39,7 @@ public class InputFileBuilderFactoryTest {
AnalysisMode analysisMode = mock(AnalysisMode.class);
InputFileBuilderFactory factory = new InputFileBuilderFactory(ProjectDefinition.create().setKey("struts"), pathResolver, langDetectionFactory,
- statusDetectionFactory, analysisMode);
+ statusDetectionFactory, analysisMode, new Settings());
InputFileBuilder builder = factory.create(fs);
assertThat(builder.langDetection()).isNotNull();
diff --git a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
index cf2a1cbe22b..3d1eb9b050d 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/scan/filesystem/InputFileBuilderTest.java
@@ -26,6 +26,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DeprecatedDefaultInputFile;
+import org.sonar.api.config.Settings;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.api.utils.PathUtils;
import org.sonar.batch.bootstrap.AnalysisMode;
@@ -66,7 +67,7 @@ public class InputFileBuilderTest {
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode);
+ langDetection, statusDetection, fs, analysisMode, new Settings());
DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.complete(inputFile, InputFile.Type.MAIN);
@@ -92,7 +93,7 @@ public class InputFileBuilderTest {
when(fs.baseDir()).thenReturn(basedir);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode);
+ langDetection, statusDetection, fs, analysisMode, new Settings());
DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
assertThat(inputFile).isNull();
@@ -112,7 +113,7 @@ public class InputFileBuilderTest {
when(langDetection.language(any(InputFile.class))).thenReturn(null);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode);
+ langDetection, statusDetection, fs, analysisMode, new Settings());
DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.complete(inputFile, InputFile.Type.MAIN);
@@ -139,7 +140,7 @@ public class InputFileBuilderTest {
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode);
+ langDetection, statusDetection, fs, analysisMode, new Settings());
DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.complete(inputFile, InputFile.Type.MAIN);
@@ -168,7 +169,7 @@ public class InputFileBuilderTest {
.thenReturn(InputFile.Status.ADDED);
InputFileBuilder builder = new InputFileBuilder("struts", new PathResolver(),
- langDetection, statusDetection, fs, analysisMode);
+ langDetection, statusDetection, fs, analysisMode, new Settings());
DeprecatedDefaultInputFile inputFile = builder.create(srcFile);
inputFile = builder.complete(inputFile, InputFile.Type.MAIN);