Search in sources :

Example 21 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class QualityGateTest method test_status_ok.

@Test
public void test_status_ok() throws IOException {
    QualityGate simple = qgClient().create("SimpleWithHighThreshold");
    qgClient().setDefault(simple.id());
    qgClient().createCondition(NewCondition.create(simple.id()).metricKey("ncloc").operator("GT").warningThreshold("40"));
    try {
        SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample"));
        BuildResult buildResult = orchestrator.executeBuild(build);
        verifyQGStatusInPostTask(buildResult, TASK_STATUS_SUCCESS, QG_STATUS_OK);
        assertThat(getGateStatusMeasure().getValue()).isEqualTo("OK");
    } finally {
        qgClient().unsetDefault();
        qgClient().destroy(simple.id());
    }
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) QualityGate(org.sonar.wsclient.qualitygate.QualityGate) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 22 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class EventTest method executeAnalysis.

private static void executeAnalysis(String... properties) {
    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample")).setProperties(properties);
    orchestrator.executeBuild(sampleProject);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 23 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class MyAccountPageTest method analyzeProject.

private static void analyzeProject(String projectKey) {
    SonarScanner build = SonarScanner.create(projectDir("qualitygate/xoo-sample")).setProjectKey(projectKey).setProperty("sonar.projectDescription", "Description of a project").setProperty("sonar.links.homepage", "http://example.com");
    orchestrator.executeBuild(build);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 24 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class IssueJsonReportTest method test_json_report_on_root_module.

/**
   * Multi-modules project
   */
@Test
public void test_json_report_on_root_module() throws Exception {
    orchestrator.getServer().restoreProfile(getResource("/one-issue-per-line.xml"));
    orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Sonar :: Integration Tests :: Multi-modules Sample");
    orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
    File rootDir = ItUtils.projectDir("shared/xoo-multi-modules-sample");
    SonarScanner scan = SonarScanner.create(rootDir).setProperty("sonar.projectDate", "2013-05-01");
    orchestrator.executeBuild(scan);
    // issues mode scan -> no new issues
    SonarScanner issuesModeScan = SonarScanner.create(rootDir).setProperty("sonar.analysis.mode", "issues").setProperty("sonar.userHome", temp.newFolder().getAbsolutePath()).setProperty("sonar.report.export.path", "sonar-report.json").setProperty("sonar.projectDate", "2013-05-02");
    orchestrator.executeBuild(issuesModeScan);
    File report = new File(rootDir, ".sonar/sonar-report.json");
    assertThat(report).isFile().exists();
    String json = sanitize(FileUtils.readFileToString(report));
    String expectedJson = expected("report-on-root-module.json");
    JSONAssert.assertEquals(expectedJson, json, false);
}
Also used : File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 25 with SonarScanner

use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.

the class IssuesModeTest method issues_analysis_on_new_project.

@Test
public void issues_analysis_on_new_project() throws IOException {
    restoreProfile("one-issue-per-line.xml");
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    SonarScanner runner = configureRunnerIssues("shared/xoo-sample", null, "sonar.verbose", "true");
    BuildResult result = orchestrator.executeBuild(runner);
    assertThat(ItUtils.countIssuesInJsonReport(result, true)).isEqualTo(17);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Aggregations

SonarScanner (com.sonar.orchestrator.build.SonarScanner)84 Test (org.junit.Test)65 BuildResult (com.sonar.orchestrator.build.BuildResult)38 File (java.io.File)21 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)8 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 Issue (org.sonar.wsclient.issue.Issue)4 Favorites (org.sonarqube.ws.Favorites)3 SearchRequest (org.sonarqube.ws.client.favorite.SearchRequest)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 BeforeClass (org.junit.BeforeClass)2 SonarClient (org.sonar.wsclient.SonarClient)2 IssueClient (org.sonar.wsclient.issue.IssueClient)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 WebTestSuite.createSonarScanner (com.sonar.it.web.WebTestSuite.createSonarScanner)1 BuildFailureException (com.sonar.orchestrator.build.BuildFailureException)1 SonarScannerInstaller (com.sonar.orchestrator.build.SonarScannerInstaller)1 FileSystem (com.sonar.orchestrator.config.FileSystem)1