Search in sources :

Example 1 with MavenLocator

use of com.sonar.orchestrator.locator.MavenLocator 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);
}
Also used : MavenBuild(com.sonar.orchestrator.build.MavenBuild) MavenLocator(com.sonar.orchestrator.locator.MavenLocator) File(java.io.File) MavenLocation(com.sonar.orchestrator.locator.MavenLocation) Test(org.junit.Test)

Example 2 with MavenLocator

use of com.sonar.orchestrator.locator.MavenLocator in project sonar-java by SonarSource.

the class JavaClasspathTest method copyGuavaJar.

@Before
public void copyGuavaJar() {
    MavenLocation guava = MavenLocation.of("com.google.guava", "guava", "10.0.1");
    File subFolder = new File(tmp.getRoot(), "subFolder");
    File subSubFolder = new File(subFolder, "subSubFolder");
    new MavenLocator(ORCHESTRATOR.getConfiguration()).copyToDirectory(guava, subSubFolder);
    aarPath = new File(new File(TestUtils.projectDir("using-aar-dep"), "lib"), "cache-1.3.0.aar").getAbsolutePath();
    guavaJarPath = new File(subSubFolder.getAbsolutePath(), guava.getFilename()).getAbsolutePath();
    fakeGuavaJarPath = new File(new File(TestUtils.projectDir("dit-check"), "lib"), "fake-guava-1.0.jar").getAbsolutePath();
}
Also used : File(java.io.File) MavenLocator(com.sonar.orchestrator.locator.MavenLocator) MavenLocation(com.sonar.orchestrator.locator.MavenLocation) Before(org.junit.Before)

Aggregations

MavenLocation (com.sonar.orchestrator.locator.MavenLocation)2 MavenLocator (com.sonar.orchestrator.locator.MavenLocator)2 File (java.io.File)2 MavenBuild (com.sonar.orchestrator.build.MavenBuild)1 Before (org.junit.Before)1 Test (org.junit.Test)1