Search in sources :

Example 21 with BuildResult

use of com.sonar.orchestrator.build.BuildResult 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 22 with BuildResult

use of com.sonar.orchestrator.build.BuildResult 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 23 with BuildResult

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

the class ScannerTest method should_display_project_url_after_analysis.

/**
   * SONAR-4239
   */
@Test
public void should_display_project_url_after_analysis() throws IOException {
    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");
    Assume.assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("3.6"));
    BuildResult result = scan("shared/xoo-multi-modules-sample");
    assertThat(result.getLogs()).contains("/dashboard/index/com.sonarsource.it.samples:multi-modules-sample");
    result = scan("shared/xoo-multi-modules-sample", "sonar.branch", "mybranch");
    assertThat(result.getLogs()).contains("/dashboard/index/com.sonarsource.it.samples:multi-modules-sample:mybranch");
    try {
        setServerProperty(orchestrator, null, "sonar.core.serverBaseURL", "http://foo:123/sonar");
        result = scan("shared/xoo-multi-modules-sample");
        assertThat(result.getLogs()).contains("http://foo:123/sonar/dashboard/index/com.sonarsource.it.samples:multi-modules-sample");
    } finally {
        resetSettings(orchestrator, null, "sonar.core.serverBaseURL");
    }
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) Test(org.junit.Test)

Example 24 with BuildResult

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

the class IssueExclusionsTest method checkAnalysisFails.

private void checkAnalysisFails(String... properties) {
    BuildResult buildResult = scan(properties);
    assertThat(buildResult.getStatus()).isNotEqualTo(0);
    assertThat(buildResult.getLogs().indexOf("SonarException")).isGreaterThan(0);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult)

Example 25 with BuildResult

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

the class SSLTest method simple_analysis_with_server_certificate.

@Test
public void simple_analysis_with_server_certificate() throws Exception {
    startSSLTransparentReverseProxy(false);
    SonarScanner sonarScanner = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")).setScannerVersion("2.7").setProperty("sonar.host.url", "https://localhost:" + httpsPort);
    BuildResult buildResult = orchestrator.executeBuildQuietly(sonarScanner);
    assertThat(buildResult.getLastStatus()).isNotEqualTo(0);
    assertThat(buildResult.getLogs()).contains("javax.net.ssl.SSLHandshakeException");
    Path clientTruststore = Paths.get(SSLTest.class.getResource(CLIENT_TRUSTSTORE).toURI()).toAbsolutePath();
    String truststorePassword = CLIENT_TRUSTSTORE_PWD;
    buildResult = orchestrator.executeBuild(sonarScanner.setEnvironmentVariable("SONAR_SCANNER_OPTS", "-Djavax.net.ssl.trustStore=" + clientTruststore.toString() + " -Djavax.net.ssl.trustStorePassword=" + truststorePassword));
}
Also used : Path(java.nio.file.Path) BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Aggregations

BuildResult (com.sonar.orchestrator.build.BuildResult)53 Test (org.junit.Test)49 SonarScanner (com.sonar.orchestrator.build.SonarScanner)38 File (java.io.File)12 QualityGate (org.sonar.wsclient.qualitygate.QualityGate)7 JSONArray (org.json.simple.JSONArray)4 JSONObject (org.json.simple.JSONObject)4 Issue (org.sonar.wsclient.issue.Issue)3 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 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 CobolCheck (it.plugins.checks.CobolCheck)1 CppCheck (it.plugins.checks.CppCheck)1 FlexCheck (it.plugins.checks.FlexCheck)1 GroovyCheck (it.plugins.checks.GroovyCheck)1