use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaTest method should_execute_rule_on_test.
@Test
public void should_execute_rule_on_test() throws Exception {
MavenLocation junit_4_11 = MavenLocation.of("junit", "junit", "4.11");
new MavenLocator(orchestrator.getConfiguration()).copyToDirectory(junit_4_11, tmp.getRoot());
MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("java-inner-classes")).setProperty("sonar.profile", "ignored-test-check").setProperty("sonar.java.test.binaries", "target/test-classes").setProperty("sonar.java.test.libraries", new File(tmp.getRoot(), junit_4_11.getFilename()).getAbsolutePath()).setCleanPackageSonarGoals();
orchestrator.executeBuild(build);
assertThat(getMeasureAsInteger("com.sonarsource.it.samples:java-inner-classes", "violations")).isEqualTo(1);
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaTest method measures_on_directory.
@Test
public void measures_on_directory() {
MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("measures-on-directory")).setCleanPackageSonarGoals();
BuildResult result = orchestrator.executeBuildQuietly(build);
// since sonar-java 2.1 does not fail if multiple package in same directory.
assertThat(result.getLastStatus()).isEqualTo(0);
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaTest method shouldAcceptFilenamesWithDollar.
/**
* See SONAR-1865
*/
@Test
public void shouldAcceptFilenamesWithDollar() {
MavenBuild build = MavenBuild.create(TestUtils.projectPom("dollar-in-names")).setCleanPackageSonarGoals().setProperty("sonar.dynamicAnalysis", "false");
orchestrator.executeBuild(build);
WsComponents.Component file = getComponent(JavaTestSuite.keyFor("org.sonar.it.core:dollar-in-names", "dollars/", "FilenameWith$Dollar.java"));
assertThat(file).isNotNull();
assertThat(file.getName()).contains("FilenameWith$Dollar");
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaTest method should_create_issue_pom_xml.
@Test
public void should_create_issue_pom_xml() {
assumeTrue(orchestrator.getServer().version().isGreaterThanOrEquals("6.3"));
orchestrator.getServer().restoreProfile(FileLocation.ofClasspath("/profile-pom-xml.xml"));
orchestrator.getServer().provisionProject("org.sonarsource.java:test-project", "Test Project");
orchestrator.getServer().associateProjectToQualityProfile("org.sonarsource.java:test-project", "java", "java-pom-xml");
MavenBuild build = MavenBuild.create().setPom(TestUtils.projectPom("pom-xml")).setCleanPackageSonarGoals();
orchestrator.executeBuild(build);
IssueClient issueClient = orchestrator.getServer().wsClient().issueClient();
List<Issue> issues = issueClient.find(IssueQuery.create().components("org.sonarsource.java:test-project:pom.xml")).list();
assertThat(issues).hasSize(1);
assertThat(issues.iterator().next().ruleKey()).isEqualTo("squid:S3423");
}
use of com.sonar.orchestrator.build.MavenBuild in project sonar-java by SonarSource.
the class JavaTest method multiple_package_in_directory_should_not_fail.
@Test
public void multiple_package_in_directory_should_not_fail() throws Exception {
MavenBuild inspection = MavenBuild.create().setPom(TestUtils.projectPom("multiple-packages-in-directory")).setCleanPackageSonarGoals();
BuildResult result = orchestrator.executeBuildQuietly(inspection);
assertThat(result.getLastStatus()).isEqualTo(0);
inspection = MavenBuild.create().setPom(TestUtils.projectPom("multiple-packages-in-directory")).setProperty("sonar.skipPackageDesign", "true").setGoals("sonar:sonar");
result = orchestrator.executeBuildQuietly(inspection);
assertThat(result.getLastStatus()).isEqualTo(0);
}
Aggregations