Пример #1
0
 @Test
 public void should_use_new_java_libraries_property() {
   SonarScanner scanner = ditProjectSonarScanner();
   scanner.setProperty("sonar.java.binaries", "target/classes");
   scanner.setProperty("sonar.java.libraries", guavaJarPath);
   ORCHESTRATOR.executeBuild(scanner);
   assertThat(getNumberOfViolations(PROJECT_KEY_DIT)).isEqualTo(2);
 }
Пример #2
0
  @Test
  public void should_support_the_old_binaries_and_libraries_properties() {
    SonarScanner scanner = ditProjectSonarScanner();
    scanner.setProperty("sonar.binaries", "target/classes");
    scanner.setProperty("sonar.libraries", guavaJarPath);
    BuildResult buildResult = ORCHESTRATOR.executeBuildQuietly(scanner);

    assertThat(buildResult.getLogs())
        .contains(
            "sonar.binaries and sonar.libraries are not supported since version 4.0 of sonar-java-plugin,"
                + " please use sonar.java.binaries and sonar.java.libraries instead");
    assertThat(buildResult.isSuccess()).isFalse();
  }
Пример #3
0
 @Test
 public void relative_path_and_wildcard_for_binaries_should_be_supported() {
   SonarScanner scanner = ditProjectSonarScanner();
   scanner.setProperty("sonar.java.binaries", "target/../target/clas**, ");
   ORCHESTRATOR.executeBuild(scanner);
   assertThat(getNumberOfViolations(PROJECT_KEY_DIT)).isEqualTo(1);
 }
Пример #4
0
 @Test
 public void directory_of_classes_in_library_should_be_supported() throws Exception {
   SonarScanner scanner = ditProjectSonarScanner();
   scanner.setProperty("sonar.java.libraries", "target/classes");
   ORCHESTRATOR.executeBuild(scanner);
   assertThat(getNumberOfViolations(PROJECT_KEY_DIT)).isEqualTo(1);
 }
Пример #5
0
 @Test
 public void should_use_aar_library() {
   SonarScanner scanner = aarProjectSonarScanner();
   scanner.setProperty("sonar.java.libraries", aarPath);
   ORCHESTRATOR.executeBuild(scanner);
   assertThat(getNumberOfViolations(PROJECT_KEY_AAR)).isEqualTo(1);
 }
Пример #6
0
 @Test
 public void invalid_binaries_dir_should_fail_analysis() {
   SonarScanner scanner = ditProjectSonarScanner();
   scanner.setProperty("sonar.java.binaries", "target/dummy__Dir");
   BuildResult buildResult = ORCHESTRATOR.executeBuildQuietly(scanner);
   assertThat(buildResult.getStatus()).isNotEqualTo(0);
   assertThat(buildResult.getLogs())
       .contains("No files nor directories matching 'target/dummy__Dir'");
 }
Пример #7
0
  @Test
  public void should_keep_order_libs() {
    SonarScanner scanner = ditProjectSonarScanner();
    scanner.setProperty("sonar.java.binaries", "target/classes");
    scanner.setProperty("sonar.java.libraries", guavaJarPath + "," + fakeGuavaJarPath);
    scanner.setProperty("sonar.verbose", "true");
    ORCHESTRATOR.executeBuild(scanner);
    assertThat(getNumberOfViolations(PROJECT_KEY_DIT)).isEqualTo(2);

    ORCHESTRATOR.resetData();

    scanner = ditProjectSonarScanner();
    scanner.setProperty("sonar.java.binaries", "target/classes");
    scanner.setProperty("sonar.java.libraries", fakeGuavaJarPath + "," + guavaJarPath);
    scanner.setProperty("sonar.verbose", "true");
    ORCHESTRATOR.executeBuild(scanner);
    assertThat(getNumberOfViolations(PROJECT_KEY_DIT)).isEqualTo(1);
  }