Search in sources :

Example 31 with SonarScanner

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

the class IssuesModeTest method shoud_support_sonar_profile_prop.

// SONAR-8518
@Test
public void shoud_support_sonar_profile_prop() throws IOException {
    restoreProfile("one-issue-per-line.xml");
    restoreProfile("empty.xml");
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "empty");
    SonarScanner runner = configureRunner("shared/xoo-sample", "sonar.verbose", "true", "sonar.analysis.mode", "issues", "sonar.profile", "one-issue-per-line");
    BuildResult result = orchestrator.executeBuild(runner);
    ItUtils.assertIssuesInJsonReport(result, 17, 0, 0);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 32 with SonarScanner

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

the class IssuesModeTest method should_fail_if_plugin_access_secured_properties.

@Test
public void should_fail_if_plugin_access_secured_properties() throws IOException {
    // Test access from task (ie BatchSettings)
    SonarScanner runner = configureRunnerIssues("shared/xoo-sample", null, "accessSecuredFromTask", "true");
    BuildResult result = orchestrator.executeBuildQuietly(runner);
    assertThat(result.getLogs()).contains("Access to the secured property 'foo.bar.secured' is not possible in issues mode. " + "The SonarQube plugin which requires this property must be deactivated in issues mode.");
    // Test access from sensor (ie ModuleSettings)
    runner = configureRunnerIssues("shared/xoo-sample", null, "accessSecuredFromSensor", "true");
    result = orchestrator.executeBuildQuietly(runner);
    assertThat(result.getLogs()).contains("Access to the secured property 'foo.bar.secured' is not possible in issues mode. " + "The SonarQube plugin which requires this property must be deactivated in issues mode.");
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 33 with SonarScanner

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

the class TempFolderTest method should_not_use_system_tmp_dir.

// SONAR-4748
@Test
public void should_not_use_system_tmp_dir() throws Exception {
    String oldTmp = System.getProperty("java.io.tmpdir");
    try {
        File tmp = temp.newFolder();
        assertThat(tmp.list()).isEmpty();
        SonarScanner runner = configureScanner().setEnvironmentVariable("SONAR_RUNNER_OPTS", "-Djava.io.tmpdir=" + tmp.getAbsolutePath());
        orchestrator.executeBuild(runner);
        // TODO There is one remaining file waiting for SONARPLUGINS-3185
        assertThat(tmp.list()).hasSize(1);
        assertThat(tmp.list()[0]).matches("sonar-runner-batch(.*).jar");
    } finally {
        System.setProperty("java.io.tmpdir", oldTmp);
    }
}
Also used : File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 34 with SonarScanner

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

the class FileExclusionsTest method scan.

private void scan(String... properties) {
    SonarScanner build = SonarScanner.create(ItUtils.projectDir("exclusions/exclusions")).setProperties(properties);
    orchestrator.executeBuild(build);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner)

Example 35 with SonarScanner

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

the class IssueExclusionsTest method scan.

protected BuildResult scan(String... properties) {
    orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/exclusions/IssueExclusionsTest/with-many-rules.xml"));
    orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-exclusions", "Sonar :: Integration Tests :: Multi-modules With Exclusions");
    orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-exclusions", "xoo", "with-many-rules");
    SonarScanner scan = SonarScanner.create(ItUtils.projectDir(PROJECT_DIR)).setProperty("sonar.cpd.exclusions", "**/*").setProperties(properties).setProperty("sonar.verbose", "true");
    return orchestrator.executeBuildQuietly(scan);
}
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