Search in sources :

Example 36 with SonarScanner

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

the class PerfTestCase method newScanner.

/**
   * New batch analysis with most features disabled by default (empty QP, no CPD, no SCM, ...)
   */
public static SonarScanner newScanner(String sonarRunnerOpts, String... props) {
    SonarScanner scanner = SonarScanner.create().setProperties("sonar.scm.disabled", "true", "sonar.cpd.exclusions", "**").setProperties(props);
    scanner.setEnvironmentVariable("SONAR_RUNNER_OPTS", sonarRunnerOpts).setProjectDir(FileLocation.of("projects/xoo-sample").getFile());
    return scanner;
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 37 with SonarScanner

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

the class FavoriteTest method project_as_favorite_when_authenticated_and_first_analysis_and_a_project_creator_permission.

@Test
public void project_as_favorite_when_authenticated_and_first_analysis_and_a_project_creator_permission() {
    SonarScanner sampleProject = createScannerWithUserCredentials();
    addProjectCreatorPermission();
    orchestrator.executeBuild(sampleProject);
    Favorites.SearchResponse response = adminWsClient.favorites().search(new SearchRequest());
    assertThat(response.getFavoritesList()).extracting(Favorite::getKey).contains(PROJECT_KEY);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Favorites(org.sonarqube.ws.Favorites) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 38 with SonarScanner

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

the class FavoriteTest method no_project_as_favorite_when_no_project_creator_permission.

@Test
public void no_project_as_favorite_when_no_project_creator_permission() {
    SonarScanner sampleProject = createScannerWithUserCredentials();
    orchestrator.executeBuild(sampleProject);
    Favorites.SearchResponse response = adminWsClient.favorites().search(new SearchRequest());
    assertThat(response.getFavoritesList()).extracting(Favorite::getKey).doesNotContain(PROJECT_KEY);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Favorites(org.sonarqube.ws.Favorites) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 39 with SonarScanner

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

the class FavoriteTest method no_project_as_favorite_when_second_analysis.

@Test
public void no_project_as_favorite_when_second_analysis() {
    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
    orchestrator.executeBuild(sampleProject);
    sampleProject = createScannerWithUserCredentials();
    addProjectCreatorPermission();
    orchestrator.executeBuild(sampleProject);
    Favorites.SearchResponse response = adminWsClient.favorites().search(new SearchRequest());
    assertThat(response.getFavoritesList()).extracting(Favorite::getKey).doesNotContain(PROJECT_KEY);
}
Also used : SearchRequest(org.sonarqube.ws.client.favorite.SearchRequest) Favorites(org.sonarqube.ws.Favorites) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 40 with SonarScanner

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

the class IssueJsonReportTest method test_json_report_no_server_analysis.

@Test
public void test_json_report_no_server_analysis() throws Exception {
    orchestrator.getServer().restoreProfile(getResource("one-issue-per-line.xml"));
    orchestrator.getServer().provisionProject("sample", "tracking");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    File projectDir = ItUtils.projectDir("analysis/tracking/v1");
    SonarScanner issuesModeScan = SonarScanner.create(projectDir).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(projectDir, ".sonar/sonar-report.json");
    assertThat(report).isFile().exists();
    String json = sanitize(FileUtils.readFileToString(report));
    String expectedJson = expected("no-server-analysis.json");
    JSONAssert.assertEquals(expectedJson, json, false);
}
Also used : File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Aggregations

SonarScanner (com.sonar.orchestrator.build.SonarScanner)74 Test (org.junit.Test)56 BuildResult (com.sonar.orchestrator.build.BuildResult)38 File (java.io.File)17 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)3 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 SonarClient (org.sonar.wsclient.SonarClient)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 BuildFailureException (com.sonar.orchestrator.build.BuildFailureException)1 SonarScannerInstaller (com.sonar.orchestrator.build.SonarScannerInstaller)1 FileSystem (com.sonar.orchestrator.config.FileSystem)1 AbapCheck (it.plugins.checks.AbapCheck)1 CCheck (it.plugins.checks.CCheck)1 Check (it.plugins.checks.Check)1