@Before
  public void setUpProject() throws IOException {
    orchestrator.resetData();
    orchestrator
        .getServer()
        .restoreProfile(FileLocation.ofClasspath("/duplication/xoo-duplication-profile.xml"));

    FileUtils.copyDirectory(ItUtils.projectDir(PROJECT_DIR), temp.getRoot());
    projectDir = temp.getRoot();
  }
Example #2
0
 private SonarRunner configureRunner(String projectDir, String... props) throws IOException {
   SonarRunner runner =
       SonarRunner.create(
           ItUtils.projectDir(projectDir),
           "sonar.working.directory",
           temp.newFolder().getAbsolutePath(),
           "sonar.report.export.path",
           "sonar-report.json",
           "sonar.userHome",
           temp.newFolder().getAbsolutePath());
   runner.setProperties(props);
   return runner;
 }
Example #3
0
  /** SONAR-926 SONAR-5069 */
  @Test
  public void test_sonar_runner_inspection() {
    orchestrator
        .getServer()
        .restoreProfile(
            FileLocation.ofClasspath("/analysis/MultiLanguageTest/one-issue-per-line.xml"));
    orchestrator
        .getServer()
        .restoreProfile(
            FileLocation.ofClasspath("/analysis/MultiLanguageTest/one-issue-per-line-xoo2.xml"));

    orchestrator.getServer().provisionProject("multi-language-sample", "multi-language-sample");

    orchestrator
        .getServer()
        .associateProjectToQualityProfile("multi-language-sample", "xoo", "one-issue-per-line");
    orchestrator
        .getServer()
        .associateProjectToQualityProfile(
            "multi-language-sample", "xoo2", "one-issue-per-line-xoo2");

    SonarRunner build =
        SonarRunner.create().setProjectDir(ItUtils.projectDir("analysis/xoo-multi-languages"));
    BuildResult result = orchestrator.executeBuild(build);

    assertThat(result.getLogs()).contains("2 files indexed");
    assertThat(result.getLogs()).contains("Quality profile for xoo: one-issue-per-line");
    assertThat(result.getLogs()).contains("Quality profile for xoo2: one-issue-per-line-xoo2");

    // modules
    Resource project = getResource("multi-language-sample", "files", "violations");
    assertThat(project.getMeasureIntValue("files")).isEqualTo(2);
    assertThat(project.getMeasureIntValue("violations")).isEqualTo(26);

    Resource xooFile = getResource("multi-language-sample:src/sample/Sample.xoo", "violations");
    assertThat(xooFile.getMeasureIntValue("violations")).isEqualTo(13);

    Resource xoo2File = getResource("multi-language-sample:src/sample/Sample.xoo2", "violations");
    assertThat(xoo2File.getMeasureIntValue("violations")).isEqualTo(13);
  }
Example #4
0
 private void scan(String... properties) {
   SonarRunner build =
       SonarRunner.create(ItUtils.projectDir("exclusions/exclusions")).setProperties(properties);
   orchestrator.executeBuild(build);
 }