Search in sources :

Example 61 with SonarScanner

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

the class SettingsEncryptionTest method failIfEncryptedPropertyButNoSecretKey.

/**
   * SONAR-2084
   */
@Test(expected = BuildFailureException.class)
public void failIfEncryptedPropertyButNoSecretKey() throws Exception {
    // path to secret key is missing
    SonarScanner build = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")).setProperty("encryptedProperty", "{aes}9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
    orchestrator.executeBuild(build);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 62 with SonarScanner

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

the class SettingsEncryptionTest method testEncryptedProperty.

/**
   * SONAR-2084
   * SONAR-4061
   */
@Test
public void testEncryptedProperty() throws Exception {
    SonarScanner build = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")).setProperty("sonar.secretKeyPath", pathToValidSecretKey()).setProperty("sonar.login", "admin").setProperty("sonar.password", // wrong password
    "{aes}wrongencryption==").setProperty("encryptedProperty", "{aes}9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
    BuildResult result = orchestrator.executeBuildQuietly(build);
    assertThat(result.getStatus()).isNotEqualTo(0);
    assertThat(result.getLogs()).contains("Fail to decrypt the property sonar.password. Please check your secret key");
    build = SonarScanner.create(ItUtils.projectDir("shared/xoo-sample")).setProperty("sonar.secretKeyPath", pathToValidSecretKey()).setProperty("sonar.login", "{aes}evRHXHsEyPr5RjEuxUJcHA==").setProperty("sonar.password", "{aes}evRHXHsEyPr5RjEuxUJcHA==").setProperty("encryptedProperty", "{aes}9mx5Zq4JVyjeChTcVjEide4kWCwusFl7P2dSVXtg9IY=");
    // no error
    orchestrator.executeBuild(build);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 63 with SonarScanner

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

the class IssuesModeTest method concurrent_issue_mode_on_existing_project.

@Test
public void concurrent_issue_mode_on_existing_project() throws Exception {
    restoreProfile("one-issue-per-line.xml");
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    // use same working dir, because lock file is in it
    String workDirPath = temp.newFolder().getAbsolutePath();
    SonarScanner runner = configureRunner("shared/xoo-sample", "sonar.working.directory", workDirPath);
    orchestrator.executeBuild(runner);
    runConcurrentIssues(workDirPath);
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 64 with SonarScanner

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

the class LinksTest method shouldUseLinkProperties.

/**
   * SONAR-3676
   */
@Test
public void shouldUseLinkProperties() {
    SonarScanner runner = SonarScanner.create(ItUtils.projectDir("analysis/links-project")).setProperty("sonar.scm.disabled", "true");
    orchestrator.executeBuild(runner);
    verifyLinks();
}
Also used : SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 65 with SonarScanner

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

the class MultiLanguageTest method test_sonar_runner_inspection.

/**
   * SONAR-926
   * SONAR-5069
   */
@Test
public void test_sonar_runner_inspection() {
    orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/MultiLanguageTest/one-issue-per-line.xml"));
    orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/analysis/MultiLanguageTest/one-issue-per-line-xoo2.xml"));
    orchestrator.getServer().provisionProject("multi-language-sample", "multi-language-sample");
    orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo", "one-issue-per-line");
    orchestrator.getServer().associateProjectToQualityProfile("multi-language-sample", "xoo2", "one-issue-per-line-xoo2");
    SonarScanner build = SonarScanner.create().setProjectDir(ItUtils.projectDir("analysis/xoo-multi-languages"));
    BuildResult result = orchestrator.executeBuild(build);
    // 4 files: 1 .xoo, 1.xoo2, 2 .measures
    assertThat(result.getLogs()).contains("4 files indexed");
    assertThat(result.getLogs()).contains("Quality profile for xoo: one-issue-per-line");
    assertThat(result.getLogs()).contains("Quality profile for xoo2: one-issue-per-line-xoo2");
    // modules
    Map<String, Double> measures = getMeasuresAsDoubleByMetricKey(orchestrator, "multi-language-sample", "files", "violations");
    assertThat(measures.get("files")).isEqualTo(2);
    assertThat(measures.get("violations")).isEqualTo(26);
    assertThat(getMeasureAsDouble(orchestrator, "multi-language-sample:src/sample/Sample.xoo", "violations")).isEqualTo(13);
    assertThat(getMeasureAsDouble(orchestrator, "multi-language-sample:src/sample/Sample.xoo2", "violations")).isEqualTo(13);
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) ItUtils.getMeasureAsDouble(util.ItUtils.getMeasureAsDouble) 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