Search in sources :

Example 11 with SonarScanner

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

the class PluginsTest method analysis_of_project_with_all_supported_languages.

@Test
public void analysis_of_project_with_all_supported_languages() {
    SonarScanner analysis = newAnalysis();
    BuildResult result = ORCHESTRATOR.executeBuildQuietly(analysis);
    if (result.getLastStatus() != 0) {
        fail(result.getLogs());
    }
    for (Check check : CHECKS) {
        System.out.println(check.getClass().getSimpleName() + "...");
        check.validate(new Validation(ORCHESTRATOR, errorCollector));
    }
}
Also used : Validation(it.plugins.checks.Validation) BuildResult(com.sonar.orchestrator.build.BuildResult) PliCheck(it.plugins.checks.PliCheck) PhpCheck(it.plugins.checks.PhpCheck) Check(it.plugins.checks.Check) JavaCheck(it.plugins.checks.JavaCheck) AbapCheck(it.plugins.checks.AbapCheck) GroovyCheck(it.plugins.checks.GroovyCheck) PythonCheck(it.plugins.checks.PythonCheck) VbCheck(it.plugins.checks.VbCheck) SwiftCheck(it.plugins.checks.SwiftCheck) CCheck(it.plugins.checks.CCheck) RpgCheck(it.plugins.checks.RpgCheck) JavascriptCheck(it.plugins.checks.JavascriptCheck) WebCheck(it.plugins.checks.WebCheck) FlexCheck(it.plugins.checks.FlexCheck) CobolCheck(it.plugins.checks.CobolCheck) CppCheck(it.plugins.checks.CppCheck) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 12 with SonarScanner

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

the class ProjectAdministrationTest method delete_version_of_multimodule_project.

// SONAR-4203
@Test
@Ignore("refactor with wsClient")
public void delete_version_of_multimodule_project() {
    GregorianCalendar today = new GregorianCalendar();
    SonarScanner build = SonarScanner.create(projectDir("shared/xoo-multi-modules-sample")).setProperty("sonar.dynamicAnalysis", "false").setProperty("sonar.projectDate", (today.get(Calendar.YEAR) - 1) + "-01-01");
    orchestrator.executeBuild(build);
    // The analysis must be run once again to have an history so that it is possible
    // to set/delete version on old snapshot
    build.setProperty("sonar.projectDate", today.get(Calendar.YEAR) + "-01-01");
    orchestrator.executeBuild(build);
    // There are 7 modules
    assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(1);
    runSelenese(orchestrator, "/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-modify-version.html");
    assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(2);
    runSelenese(orchestrator, "/projectAdministration/ProjectAdministrationTest/project-administration/multimodule-project-delete-version.html");
    assertThat(count("events where category='Version'")).as("Different number of events").isEqualTo(1);
}
Also used : GregorianCalendar(java.util.GregorianCalendar) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with SonarScanner

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

the class ProjectAdministrationTest method project_deletion.

/**
   * Test updated for SONAR-3570 and SONAR-5923
   */
@Test
public void project_deletion() {
    String projectAdminUser = "project-deletion-with-admin-permission-on-project";
    SonarClient wsClient = orchestrator.getServer().adminWsClient();
    try {
        SonarScanner scan = SonarScanner.create(projectDir("shared/xoo-sample"));
        orchestrator.executeBuild(scan);
        // Create user having admin permission on previously analysed project
        wsClient.userClient().create(UserParameters.create().login(projectAdminUser).name(projectAdminUser).password("password").passwordConfirmation("password"));
        wsClient.post("api/permissions/add_user", "login", projectAdminUser, "projectKey", "sample", "permission", "admin");
        runSelenese(orchestrator, "/projectAdministration/ProjectAdministrationTest/project-deletion/project-deletion.html");
    } finally {
        wsClient.userClient().deactivate(projectAdminUser);
    }
}
Also used : SonarClient(org.sonar.wsclient.SonarClient) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 14 with SonarScanner

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

the class ProjectAdministrationTest method scanSample.

private void scanSample(@Nullable String date, @Nullable String profile) {
    SonarScanner scan = SonarScanner.create(projectDir("shared/xoo-sample")).setProperty("sonar.cpd.exclusions", "**/*");
    if (date != null) {
        scan.setProperty("sonar.projectDate", date);
    }
    if (profile != null) {
        scan.setProfile(profile);
    }
    orchestrator.executeBuild(scan);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 15 with SonarScanner

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

the class IssueCreationDateTest method analysis.

private void analysis(QProfile qProfile, SourceCode sourceCode, ScannerFeature... scm) {
    server.restoreProfile(FileLocation.ofClasspath(qProfile.path));
    server.associateProjectToQualityProfile(SAMPLE_PROJECT_KEY, LANGUAGE_XOO, SAMPLE_QUALITY_PROFILE_NAME);
    SonarScanner scanner = SonarScanner.create(projectDir(sourceCode.path));
    Arrays.stream(scm).forEach(s -> s.configure(scanner));
    ORCHESTRATOR.executeBuild(scanner);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

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