Search in sources :

Example 26 with BuildResult

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

the class ScannerTest method should_display_explicit_message_when_no_plugin_language_available.

/**
   * SONAR-3125
   */
@Test
public void should_display_explicit_message_when_no_plugin_language_available() {
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    BuildResult buildResult = scanQuietly("shared/xoo-sample", "sonar.language", "foo", "sonar.profile", "");
    assertThat(buildResult.getLastStatus()).isEqualTo(1);
    assertThat(buildResult.getLogs()).contains("You must install a plugin that supports the language 'foo'");
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) Test(org.junit.Test)

Example 27 with BuildResult

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

the class ScannerTest method display_MessageException_without_stacktrace.

/**
   * SONAR-4547
   */
@Test
public void display_MessageException_without_stacktrace() throws Exception {
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    BuildResult result = scanQuietly("shared/xoo-sample", "raiseMessageException", "true");
    assertThat(result.getLastStatus()).isNotEqualTo(0);
    assertThat(result.getLogs()).contains("Error message from plugin").doesNotContain("at com.sonarsource.RaiseMessageException");
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) Test(org.junit.Test)

Example 28 with BuildResult

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

the class ScannerTest method should_honor_sonarUserHome.

@Test
public void should_honor_sonarUserHome() {
    File userHome = temp.getRoot();
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    SonarScanner scanner = configureScanner("shared/xoo-sample", "sonar.verbose", "true");
    scanner.setEnvironmentVariable("SONAR_USER_HOME", "/dev/null");
    BuildResult buildResult = orchestrator.executeBuildQuietly(scanner);
    assertThat(buildResult.getLastStatus()).isEqualTo(1);
    buildResult = scan("shared/xoo-sample", "sonar.verbose", "true", "sonar.userHome", userHome.getAbsolutePath());
    assertThat(buildResult.isSuccess()).isTrue();
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) File(java.io.File) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Example 29 with BuildResult

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

the class ScannerTest method should_display_explicit_message_when_invalid_project_key_or_branch.

/**
   * SONAR-4188, SONAR-5178, SONAR-5915
   */
@Test
public void should_display_explicit_message_when_invalid_project_key_or_branch() {
    orchestrator.getServer().provisionProject("sample", "xoo-sample");
    orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    BuildResult buildResult = scanQuietly("shared/xoo-sample", "sonar.projectKey", "ar g$l:");
    assertThat(buildResult.getLastStatus()).isEqualTo(1);
    assertThat(buildResult.getLogs()).contains("\"ar g$l:\" is not a valid project or module key").contains("Allowed characters");
    // SONAR-4629
    buildResult = scanQuietly("shared/xoo-sample", "sonar.projectKey", "12345");
    assertThat(buildResult.getLastStatus()).isEqualTo(1);
    assertThat(buildResult.getLogs()).contains("\"12345\" is not a valid project or module key").contains("Allowed characters");
    buildResult = scanQuietly("shared/xoo-sample", "sonar.branch", "ar g$l:");
    assertThat(buildResult.getLastStatus()).isEqualTo(1);
    assertThat(buildResult.getLogs()).contains("\"ar g$l:\" is not a valid branch").contains("Allowed characters");
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) Test(org.junit.Test)

Example 30 with BuildResult

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

the class ScannerTest method batch_should_cache_plugin_jars.

/**
   * SONAR-2291
   */
@Test
public void batch_should_cache_plugin_jars() throws IOException {
    File userHome = temp.newFolder();
    BuildResult result = scan("shared/xoo-sample", "sonar.userHome", userHome.getAbsolutePath());
    File cache = new File(userHome, "cache");
    assertThat(cache).exists().isDirectory();
    int cachedFiles = FileUtils.listFiles(cache, new String[] { "jar" }, true).size();
    assertThat(cachedFiles).isGreaterThan(5);
    assertThat(result.getLogs()).contains("User cache: " + cache.getAbsolutePath());
    assertThat(result.getLogs()).contains("Download sonar-xoo-plugin-");
    result = scan("shared/xoo-sample", "sonar.userHome", userHome.getAbsolutePath());
    assertThat(cachedFiles).isEqualTo(cachedFiles);
    assertThat(result.getLogs()).contains("User cache: " + cache.getAbsolutePath());
    assertThat(result.getLogs()).doesNotContain("Download sonar-xoo-plugin-");
}
Also used : BuildResult(com.sonar.orchestrator.build.BuildResult) File(java.io.File) 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