Search in sources :

Example 26 with MavenBuild

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

the class JavaTest method shouldDetectCommentedOutCode.

/**
 * Since 2.13 commented-out code lines not saved as measure for Java - see SONAR-3093
 */
@Test
public void shouldDetectCommentedOutCode() {
    MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("commented-out-java-code")).setCleanSonarGoals().setProperty("sonar.dynamicAnalysis", "false");
    orchestrator.executeBuild(build);
    assertThat(getMeasureAsInteger("com.sonarsource.it.samples:commented-out-java-code", "ncloc")).isEqualTo(7);
    assertThat(getMeasureAsInteger("com.sonarsource.it.samples:commented-out-java-code", "commented_out_code_lines")).isNull();
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Test(org.junit.Test)

Example 27 with MavenBuild

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

the class JavaRulingTest method apache_commons_beanutils.

@Test
public void apache_commons_beanutils() throws Exception {
    String projectName = "commons-beanutils";
    MavenBuild build = test_project("commons-beanutils:commons-beanutils", projectName);
    executeBuildWithCommonProperties(build, projectName);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Test(org.junit.Test)

Example 28 with MavenBuild

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

the class SemanticTest method test_project.

private static void test_project(String projectKey, @Nullable String path, String projectName) throws IOException {
    prepareProject(projectKey, projectName);
    String pomLocation = "../../sources/" + (path != null ? path + "/" : "") + projectName + "/pom.xml";
    MavenBuild mavenBuild = MavenBuild.create().setPom(FileLocation.of(pomLocation).getFile()).setCleanPackageSonarGoals().addArgument("-DskipTests");
    executeBuildWithCommonProperties(mavenBuild, projectName);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild)

Example 29 with MavenBuild

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

the class SuppressWarningTest method suppressWarnings_nosonar.

/**
 * SONARJAVA-19
 */
@Test
public void suppressWarnings_nosonar() throws Exception {
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("suppress-warnings")).setCleanSonarGoals().setProperty("sonar.java.binaries", "target").setProperty("sonar.profile", "suppress-warnings");
    ORCHESTRATOR.executeBuild(build);
    assertThat(parseInt(getMeasure("org.example:example", "violations").getValue())).isEqualTo(4);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Test(org.junit.Test)

Example 30 with MavenBuild

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

the class JavaClasspathTest method mavenOnDitProject.

private static void mavenOnDitProject(String goal) {
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("dit-check")).setGoals(goal).setProperty("sonar.profile", "dit-check").setProperty("sonar.dynamicAnalysis", "false");
    ORCHESTRATOR.executeBuild(build);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild)

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