use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class PermissionSearchTest method analyzeProject.
@BeforeClass
public static void analyzeProject() {
orchestrator.resetData();
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/authorisation/one-issue-per-line-profile.xml"));
orchestrator.getServer().provisionProject(PROJECT_KEY, "Sample");
orchestrator.getServer().associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
orchestrator.executeBuild(sampleProject);
adminWsClient = newAdminWsClient(orchestrator);
permissionsWsClient = adminWsClient.permissions();
createUser(LOGIN, "George Orwell");
createGroup(GROUP_NAME);
}
use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class ProjectsWsTest method projects_web_service.
/**
* SONAR-3105
*/
@Test
public void projects_web_service() throws IOException {
SonarScanner build = SonarScanner.create(projectDir("shared/xoo-sample"));
orchestrator.executeBuild(build);
String url = orchestrator.getServer().getUrl() + "/api/projects/index?key=sample&versions=true";
HttpClient httpclient = new DefaultHttpClient();
try {
HttpGet get = new HttpGet(url);
HttpResponse response = httpclient.execute(get);
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
String content = IOUtils.toString(response.getEntity().getContent());
assertThat(content).doesNotContain("error");
assertThat(content).contains("sample");
EntityUtils.consume(response.getEntity());
} finally {
httpclient.getConnectionManager().shutdown();
}
}
use of com.sonar.orchestrator.build.SonarScanner 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));
}
use of com.sonar.orchestrator.build.SonarScanner 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();
}
use of com.sonar.orchestrator.build.SonarScanner in project sonarqube by SonarSource.
the class IssueJsonReportTest method test_json_report_on_sub_module.
/**
* Multi-modules project but Eclipse scans only a single module
*/
@Test
public void test_json_report_on_sub_module() throws Exception {
orchestrator.getServer().restoreProfile(getResource("one-issue-per-line.xml"));
orchestrator.getServer().provisionProject("com.sonarsource.it.samples:multi-modules-sample", "Multi-module sample");
orchestrator.getServer().associateProjectToQualityProfile("com.sonarsource.it.samples:multi-modules-sample", "xoo", "one-issue-per-line");
File rootDir = ItUtils.projectDir("shared/xoo-multi-modules-sample");
SonarScanner scan = SonarScanner.create(rootDir).setProperty("sonar.projectDate", "2013-05-01");
orchestrator.executeBuild(scan);
// Issues mode scan on a module -> no new issues
File moduleDir = ItUtils.projectDir("shared/xoo-multi-modules-sample/module_a/module_a1");
SonarScanner issuesModeScan = SonarScanner.create(moduleDir).setProperty("sonar.projectKey", "com.sonarsource.it.samples:multi-modules-sample:module_a:module_a1").setProperty("sonar.projectVersion", "1.0-SNAPSHOT").setProperty("sonar.projectName", "ModuleA1").setProperty("sonar.sources", "src/main/xoo").setProperty("sonar.language", "xoo").setProperty("sonar.analysis.mode", "issues").setProperty("sonar.userHome", temp.newFolder().getAbsolutePath()).setProperty("sonar.report.export.path", "sonar-report.json").setProperty("sonar.projectDate", "2013-05-02");
orchestrator.executeBuild(issuesModeScan);
File report = new File(moduleDir, ".sonar/sonar-report.json");
assertThat(report).isFile().exists();
String json = sanitize(FileUtils.readFileToString(report));
// SONAR-5218 All issues are updated as their root project id has changed (it's now the sub module)
String expectedJson = expected("report-on-sub-module.json");
JSONAssert.assertEquals(expectedJson, json, false);
}
Aggregations