Search in sources :

Example 16 with MavenBuild

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

the class JavaTest method shouldFailIfInvalidJavaPackage.

/**
 * SONARJAVA-444
 */
@Test
public void shouldFailIfInvalidJavaPackage() {
    MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("invalid-java-package")).setCleanSonarGoals();
    BuildResult buildResult = orchestrator.executeBuildQuietly(build);
    assertThat(buildResult.getLastStatus()).isEqualTo(0);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) BuildResult(com.sonar.orchestrator.build.BuildResult) Test(org.junit.Test)

Example 17 with MavenBuild

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

the class JavaTest method filtered_issues.

/**
 * SONARJAVA-1615
 */
@Test
public void filtered_issues() throws Exception {
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("filtered-issues")).setCleanPackageSonarGoals().setProperty("sonar.profile", "filtered-issues");
    orchestrator.executeBuild(build);
    assertThat(getMeasureAsInteger("org.example:example", "violations")).isEqualTo(2);
    IssueClient issueClient = orchestrator.getServer().wsClient().issueClient();
    List<Issue> issues = issueClient.find(IssueQuery.create().components("org.example:example:src/main/java/EclispeI18NFiltered.java")).list();
    assertThat(issues).hasSize(2);
    for (Issue issue : issues) {
        assertThat(issue.ruleKey()).matches(value -> "squid:S1444".equals(value) || "squid:ClassVariableVisibilityCheck".equals(value));
        assertThat(issue.line()).isEqualTo(17);
    }
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Issue(org.sonar.wsclient.issue.Issue) IssueClient(org.sonar.wsclient.issue.IssueClient) Test(org.junit.Test)

Example 18 with MavenBuild

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

the class Struts139Test method analyzeProject.

@BeforeClass
public static void analyzeProject() {
    orchestrator.resetData();
    MavenBuild build = MavenBuild.create(TestUtils.projectPom("struts-1.3.9-lite"));
    build.setGoals("org.jacoco:jacoco-maven-plugin:prepare-agent clean verify");
    MavenBuild analysis = MavenBuild.create(TestUtils.projectPom("struts-1.3.9-lite")).setProperty("sonar.scm.disabled", "true").setProperty("sonar.exclusions", "**/pom.xml").setGoals("sonar:sonar");
    orchestrator.executeBuilds(build, analysis);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) BeforeClass(org.junit.BeforeClass)

Example 19 with MavenBuild

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

the class JavaRulingTest method sonarqube_server.

@Test
public void sonarqube_server() throws Exception {
    // sonarqube-6.5/server/sonar-server (v.6.5)
    String projectName = "sonar-server";
    MavenBuild build = test_project("org.sonarsource.sonarqube:sonar-server", "sonarqube-6.5/server", projectName);
    executeBuildWithCommonProperties(build, projectName);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) Test(org.junit.Test)

Example 20 with MavenBuild

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

the class JavaRulingTest method guava.

@Test
public void guava() throws Exception {
    String projectName = "guava";
    MavenBuild build = test_project("com.google.guava:guava", projectName);
    executeBuildWithCommonProperties(build, projectName);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) 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