Search in sources :

Example 21 with MavenBuild

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

the class LinksTest method shouldUseLinkPropertiesOverPomLinksInMaven.

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

Example 22 with MavenBuild

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

the class ProjectBuilderTest method shouldDefineProjectFromPlugin.

@Test
public void shouldDefineProjectFromPlugin() {
    MavenBuild build = MavenBuild.create(ItUtils.projectPom("analysis/project-builder")).setCleanSonarGoals().setProperty("sonar.enableProjectBuilder", "true").setProperty("sonar.dynamicAnalysis", "false");
    orchestrator.executeBuild(build);
    checkProject();
    checkSubProject("project-builder-module-a");
    checkSubProject("project-builder-module-b");
    checkFile("project-builder-module-a", "src/HelloA.java");
    checkFile("project-builder-module-b", "src/HelloB.java");
    assertThat(getComponent(orchestrator, "com.sonarsource.it.projects.batch:project-builder-module-b:src/IgnoredFile.java")).isNull();
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Test(org.junit.Test)

Example 23 with MavenBuild

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

the class WebTest method scan_struts.

@BeforeClass
public static void scan_struts() throws Exception {
    FileLocation strutsHome = orchestrator.getFileLocationOfShared("it-sonar-performancing/struts-1.3.9/pom.xml");
    MavenBuild scan = MavenBuild.create(strutsHome.getFile());
    scan.setGoals("sonar:sonar -V");
    scan.setEnvironmentVariable("MAVEN_OPTS", "-Xmx512m -server");
    scan.setProperty("sonar.scm.disabled", "true");
    scan.setProperty("sonar.sourceEncoding", "UTF-8");
    orchestrator.executeBuild(scan);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) FileLocation(com.sonar.orchestrator.locator.FileLocation) BeforeClass(org.junit.BeforeClass)

Example 24 with MavenBuild

use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.

the class JaCoCoControllerTest method test_coverage_per_test.

@Test
public void test_coverage_per_test() throws Exception {
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("coverage_error")).setProperty("skipTests", "false").setProperty("javaPluginVersion", javaVersion).setGoals("org.jacoco:jacoco-maven-plugin:prepare-agent clean verify", "sonar:sonar");
    BuildResult buildResult = orchestrator.executeBuildQuietly(build);
    assertThat(buildResult.isSuccess()).isTrue();
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) BuildResult(com.sonar.orchestrator.build.BuildResult) Test(org.junit.Test)

Example 25 with MavenBuild

use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.

the class JavaTest method java_aware_visitor_rely_on_java_version.

@Test
public void java_aware_visitor_rely_on_java_version() {
    String sonarJavaSource = "sonar.java.source";
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("java-version-aware-visitor")).setCleanSonarGoals().setProperty("sonar.profile", "java-version-aware-visitor");
    // no java version specified. maven scanner gets maven default version : java 5.
    orchestrator.executeBuild(build);
    assertThat(getMeasureAsInteger("org.example:example", "violations")).isEqualTo(0);
    // invalid java version. got issue on java 7 code
    build.setProperty(sonarJavaSource, "jdk_1.6");
    BuildResult buildResult = orchestrator.executeBuild(build);
    // build should not fail
    assertThat(buildResult.getLastStatus()).isEqualTo(0);
    // build logs should contains warning related to sources
    assertThat(buildResult.getLogs()).contains("Invalid java version");
    assertThat(getMeasureAsInteger("org.example:example", "violations")).isEqualTo(1);
    // upper version. got issue on java 7 code
    build.setProperty(sonarJavaSource, "1.8");
    orchestrator.executeBuild(build);
    assertThat(getMeasureAsInteger("org.example:example", "violations")).isEqualTo(1);
    // lower version. no issue on java 7 code
    build.setProperty(sonarJavaSource, "1.6");
    orchestrator.executeBuild(build);
    assertThat(getMeasureAsInteger("org.example:example", "violations")).isEqualTo(0);
    SonarScanner scan = SonarScanner.create(TestUtils.projectDir("java-version-aware-visitor")).setProperty("sonar.projectKey", "org.example:example-scanner").setProperty("sonar.projectName", "example").setProperty("sonar.projectVersion", "1.0-SNAPSHOT").setProperty("sonar.profile", "java-version-aware-visitor").setProperty("sonar.sources", "src/main/java");
    orchestrator.executeBuild(scan);
    // no java version specified, got issue on java 7 code
    assertThat(getMeasureAsInteger("org.example:example-scanner", "violations")).isEqualTo(1);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) BuildResult(com.sonar.orchestrator.build.BuildResult) SonarScanner(com.sonar.orchestrator.build.SonarScanner) Test(org.junit.Test)

Aggregations

MavenBuild (com.sonar.orchestrator.build.MavenBuild)30 Test (org.junit.Test)23 BuildResult (com.sonar.orchestrator.build.BuildResult)7 BeforeClass (org.junit.BeforeClass)4 Issue (org.sonar.wsclient.issue.Issue)3 IssueClient (org.sonar.wsclient.issue.IssueClient)3 File (java.io.File)2 Measure (org.sonarqube.ws.WsMeasures.Measure)2 SonarScanner (com.sonar.orchestrator.build.SonarScanner)1 FileLocation (com.sonar.orchestrator.locator.FileLocation)1 MavenLocation (com.sonar.orchestrator.locator.MavenLocation)1 MavenLocator (com.sonar.orchestrator.locator.MavenLocator)1 Double.parseDouble (java.lang.Double.parseDouble)1 WsComponents (org.sonarqube.ws.WsComponents)1