use of org.sonar.scanner.mediumtest.ScannerMediumTester.AnalysisBuilder in project sonarqube by SonarSource.
the class HighlightingMediumTest method computeInvalidOffsets.
@Test
public void computeInvalidOffsets() throws IOException {
File baseDir = temp.newFolder();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
File xoohighlightingFile = new File(srcDir, "sample.xoo.highlighting");
FileUtils.write(xooFile, "Sample xoo\ncontent plop");
FileUtils.write(xoohighlightingFile, "1:0:1:10:s\n2:18:2:18:k");
AnalysisBuilder analysisBuilder = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.projectName", "Foo Project").put("sonar.projectVersion", "1.0-SNAPSHOT").put("sonar.projectDescription", "Description of Foo Project").put("sonar.sources", "src").build());
assertThatThrownBy(() -> analysisBuilder.execute()).isInstanceOf(IllegalStateException.class).hasMessageContaining("Error processing line 2").hasCauseInstanceOf(IllegalArgumentException.class);
}
use of org.sonar.scanner.mediumtest.ScannerMediumTester.AnalysisBuilder in project sonarqube by SonarSource.
the class ScmMediumTest method forceReload.
@Test
public void forceReload() throws IOException, URISyntaxException {
File baseDir = prepareProject();
File xooFileNoScm = new File(baseDir, SAME_CONTENT_SCM_ON_SERVER_XOO);
FileUtils.write(xooFileNoScm, SAMPLE_XOO_CONTENT, StandardCharsets.UTF_8);
File xooScmFile = new File(baseDir, SAME_CONTENT_SCM_ON_SERVER_XOO + ".scm");
FileUtils.write(xooScmFile, // revision,author,dateTime
"1,foo,2013-01-04\n" + "1,bar,2013-01-04\n", StandardCharsets.UTF_8);
AnalysisBuilder analysisBuilder = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.sources", "src").put("sonar.scm.provider", "xoo").put("sonar.scm.forceReloadAll", "true").build());
analysisBuilder.execute();
ScannerReport.Changesets file1Scm = getChangesets(baseDir, "src/sample.xoo");
assertThat(file1Scm).isNotNull();
ScannerReport.Changesets file2Scm = getChangesets(baseDir, SAME_CONTENT_SCM_ON_SERVER_XOO);
assertThat(file2Scm).isNotNull();
}
use of org.sonar.scanner.mediumtest.ScannerMediumTester.AnalysisBuilder in project sonarqube by SonarSource.
the class FileSystemMediumTest method scanProjectWithWrongCase.
// SONAR-6719
@Test
public void scanProjectWithWrongCase() {
// To please the quality gate, don't use assumeTrue, or the test will be reported as skipped
File projectDir = new File("test-resources/mediumtest/xoo/sample");
AnalysisBuilder analysis = tester.newAnalysis(new File(projectDir, "sonar-project.properties")).property("sonar.sources", "XOURCES").property("sonar.tests", "TESTX").property("sonar.scm.exclusions.disabled", "true");
if (System2.INSTANCE.isOsWindows()) {
// Windows is file path case-insensitive
AnalysisResult result = analysis.execute();
assertThat(result.inputFiles()).hasSize(8);
assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly("testx/ClassOneTest.xoo.measures", "xources/hello/helloscala.xoo.measures", "xources/hello/HelloJava.xoo.measures", "testx/ClassOneTest.xoo", "xources/hello/HelloJava.xoo.scm", "xources/hello/helloscala.xoo", "testx/ClassOneTest.xoo.scm", "xources/hello/HelloJava.xoo");
} else if (System2.INSTANCE.isOsMac()) {
AnalysisResult result = analysis.execute();
assertThat(result.inputFiles()).hasSize(8);
assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly("TESTX/ClassOneTest.xoo.measures", "XOURCES/hello/helloscala.xoo.measures", "XOURCES/hello/HelloJava.xoo.measures", "TESTX/ClassOneTest.xoo", "XOURCES/hello/HelloJava.xoo.scm", "XOURCES/hello/helloscala.xoo", "TESTX/ClassOneTest.xoo.scm", "XOURCES/hello/HelloJava.xoo");
} else {
assertThatThrownBy(() -> analysis.execute()).isInstanceOf(MessageException.class).hasMessageContaining("The folder 'TESTX' does not exist for 'sample'");
}
}
use of org.sonar.scanner.mediumtest.ScannerMediumTester.AnalysisBuilder in project sonarqube by SonarSource.
the class FileSystemMediumTest method two_languages_with_same_extension.
@Test
public void two_languages_with_same_extension() throws IOException {
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
writeFile(srcDir, "sample.xoo", "Sample xoo\ncontent");
writeFile(srcDir, "sample.xoo2", "Sample xoo 2\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.sources", "src").build()).execute();
assertThat(result.inputFiles()).hasSize(2);
AnalysisBuilder analysisBuilder = tester.newAnalysis().properties(builder.put("sonar.lang.patterns.xoo2", "**/*.xoo").build());
assertThatThrownBy(analysisBuilder::execute).isInstanceOf(MessageException.class).hasMessage("Language of file 'src" + File.separator + "sample.xoo' can not be decided as the file matches patterns of both sonar.lang.patterns.xoo : **/*.xoo and sonar.lang.patterns.xoo2 : **/*.xoo");
// SONAR-9561
result = tester.newAnalysis().properties(builder.put("sonar.exclusions", "**/sample.xoo").build()).execute();
assertThat(result.inputFiles()).hasSize(1);
}
use of org.sonar.scanner.mediumtest.ScannerMediumTester.AnalysisBuilder in project sonarqube by SonarSource.
the class HighlightingMediumTest method saveTwice.
@Test
public void saveTwice() throws IOException {
File baseDir = temp.newFolder();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, "Sample xoo\ncontent plop");
AnalysisBuilder analysisBuilder = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.projectName", "Foo Project").put("sonar.projectVersion", "1.0-SNAPSHOT").put("sonar.projectDescription", "Description of Foo Project").put("sonar.sources", "src").put("sonar.it.savedatatwice", "true").build());
;
assertThatThrownBy(() -> analysisBuilder.execute()).isInstanceOf(UnsupportedOperationException.class).hasMessageContaining("Trying to save highlighting twice for the same file is not supported");
}
Aggregations