use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.
the class IssuesOnDirMediumTest method scanTempProject.
@Test
public void scanTempProject() throws IOException {
File baseDir = temp.getRoot();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile1 = new File(srcDir, "sample1.xoo");
FileUtils.write(xooFile1, "Sample1 xoo\ncontent");
File xooFile2 = new File(srcDir, "sample2.xoo");
FileUtils.write(xooFile2, "Sample2 xoo\ncontent");
TaskResult result = tester.newTask().properties(ImmutableMap.<String, String>builder().put("sonar.task", "scan").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()).start();
assertThat(result.issuesFor(result.inputDir("src"))).hasSize(2);
}
use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.
the class EmptyFileTest method testIssueTrackingWithIssueOnEmptyFile.
@Test
public void testIssueTrackingWithIssueOnEmptyFile() throws Exception {
File projectDir = copyProject("/mediumtest/xoo/sample-with-empty-file");
TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).property("sonar.xoo.internalKey", "my/internal/key").start();
for (TrackedIssue i : result.trackedIssues()) {
System.out.println(i.startLine() + " " + i.getMessage());
}
assertThat(result.trackedIssues()).hasSize(11);
}
use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.
the class ProjectBuilderMediumTest method testProjectBuilder.
@Test
public void testProjectBuilder() throws IOException {
File baseDir = prepareProject();
TaskResult result = tester.newTask().properties(ImmutableMap.<String, String>builder().put("sonar.task", "scan").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", ".").put("sonar.verbose", "true").put("sonar.xoo.enableProjectBuilder", "true").build()).start();
List<Issue> issues = result.issuesFor(result.inputFile("src/sample.xoo"));
assertThat(issues).hasSize(10);
assertThat(issues).extracting("msg", "textRange.startLine", "gap").contains(tuple("This issue is generated on each line", 1, 0.0));
}
use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.
the class ChecksMediumTest method testCheckWithTemplate.
@Test
public void testCheckWithTemplate() throws IOException {
File baseDir = temp.getRoot();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
FileUtils.write(xooFile, "foo\nbar");
TaskResult result = tester.newTask().properties(ImmutableMap.<String, String>builder().put("sonar.task", "scan").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()).start();
List<Issue> issues = result.issuesFor(result.inputFile("src/sample.xoo"));
assertThat(issues).extracting("msg", "textRange.startLine").containsOnly(tuple("A template rule", 1), tuple("Another template rule", 2));
}
use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.
the class IssuesMediumTest method testOneIssuePerLine.
@Test
public void testOneIssuePerLine() throws Exception {
File projectDir = new File(IssuesMediumTest.class.getResource("/mediumtest/xoo/sample").toURI());
File tmpDir = temp.newFolder();
FileUtils.copyDirectory(projectDir, tmpDir);
TaskResult result = tester.newScanTask(new File(tmpDir, "sonar-project.properties")).start();
List<Issue> issues = result.issuesFor(result.inputFile("xources/hello/HelloJava.xoo"));
assertThat(issues).hasSize(8);
Issue issue = issues.get(0);
assertThat(issue.getTextRange().getStartLine()).isEqualTo(issue.getTextRange().getStartLine());
}
Aggregations