Search in sources :

Example 1 with MavenBuild

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

the class DuplicationTest method hugeJavaFile.

/**
   * SONAR-3060
   */
@Test
public void hugeJavaFile() {
    MavenBuild build = MavenBuild.create(FileLocation.of("projects/huge-file/pom.xml").getFile()).setEnvironmentVariable("MAVEN_OPTS", "-Xmx1024m").setProperty("sonar.sourceEncoding", "UTF-8").setCleanSonarGoals();
    orchestrator.executeBuild(build);
    Map<String, Double> measure = getMeasures("com.sonarsource.it.samples:huge-file:src/main/java/huge/HugeFile.java");
    assertThat(measure.get("duplicated_lines")).isGreaterThan(50000.0);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Double.parseDouble(java.lang.Double.parseDouble) Test(org.junit.Test)

Example 2 with MavenBuild

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

the class UpgradeTest method scanProject.

private void scanProject() {
    MavenBuild build = MavenBuild.create(new File("projects/struts-1.3.9-diet/pom.xml")).setCleanSonarGoals().setProperty("sonar.exclusions", "**/pom.xml").setProperty("sonar.dynamicAnalysis", "false").setProperty("sonar.scm.disabled", "true").setProperty("sonar.cpd.cross_project", "true");
    orchestrator.executeBuild(build);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) File(java.io.File)

Example 3 with MavenBuild

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

the class ExtensionLifecycleTest method testInstantiationStrategyAndLifecycleOfBatchExtensions.

@Test
public void testInstantiationStrategyAndLifecycleOfBatchExtensions() {
    MavenBuild build = MavenBuild.create(ItUtils.projectPom("analysis/extension-lifecycle")).setCleanSonarGoals().setProperty("extension.lifecycle", "true").setProperty("sonar.dynamicAnalysis", "false");
    // Build fails if the extensions provided in the extension-lifecycle-plugin are not correctly
    // managed.
    orchestrator.executeBuild(build);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Test(org.junit.Test)

Example 4 with MavenBuild

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

the class SquidTest method init.

@BeforeClass
public static void init() {
    orchestrator.resetData();
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("squid")).setCleanPackageSonarGoals().setProperty("sonar.scm.disabled", "true").setProperty("sonar.profile", "squid");
    orchestrator.executeBuild(build);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) BeforeClass(org.junit.BeforeClass)

Example 5 with MavenBuild

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

the class UnitTestsTest method tests_without_main_code.

@Test
public void tests_without_main_code() {
    MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("tests-without-main-code")).setGoals("clean test-compile surefire:test", "sonar:sonar");
    orchestrator.executeBuild(build);
    Map<String, Measure> measures = getMeasures("com.sonarsource.it.samples:tests-without-main-code", "tests", "test_errors", "test_failures", "skipped_tests", "test_execution_time", "test_success_density");
    assertThat(parseInt(measures.get("tests").getValue())).isEqualTo(1);
    assertThat(parseInt(measures.get("test_errors").getValue())).isEqualTo(0);
    assertThat(parseInt(measures.get("test_failures").getValue())).isEqualTo(0);
    assertThat(parseInt(measures.get("skipped_tests").getValue())).isEqualTo(1);
    assertThat(parseInt(measures.get("test_execution_time").getValue())).isGreaterThan(0);
    assertThat(parseDouble(measures.get("test_success_density").getValue())).isEqualTo(100.0);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Measure(org.sonarqube.ws.WsMeasures.Measure) 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