Пример #1
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);
 }
Пример #2
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);
 }
Пример #3
0
 @Test
 public void should_use_new_java_binaries_property() {
   SonarScanner scanner = ditProjectSonarScanner();
   scanner.setProperty("sonar.java.binaries", "target/classes");
   ORCHESTRATOR.executeBuild(scanner);
   assertThat(getNumberOfViolations(PROJECT_KEY_DIT)).isEqualTo(1);
 }
Пример #4
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);
 }
Пример #5
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'");
 }
Пример #6
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();
  }
Пример #7
0
 private static SonarScanner ditProjectSonarScanner() {
   return SonarScanner.create(TestUtils.projectDir("dit-check"))
       .setProperty("sonar.projectKey", PROJECT_KEY_DIT)
       .setProperty("sonar.projectName", "dit-check")
       .setProperty("sonar.projectVersion", "1.0-SNAPSHOT")
       .setProperty("sonar.profile", "dit-check")
       .setProperty("sonar.sources", "src/main/java");
 }
Пример #8
0
 private static SonarScanner aarProjectSonarScanner() {
   return SonarScanner.create(TestUtils.projectDir("using-aar-dep"))
       .setProperty("sonar.projectKey", PROJECT_KEY_AAR)
       .setProperty("sonar.projectName", "using-aar-dep")
       .setProperty("sonar.projectVersion", "1.0-SNAPSHOT")
       .setProperty("sonar.profile", "using-aar-dep")
       .setProperty("sonar.sources", "src/main/java");
 }
Пример #9
0
  @BeforeClass
  public static void setUp() {
    wsClient = newAdminWsClient(ORCHESTRATOR);

    ORCHESTRATOR.resetData();
    ORCHESTRATOR.executeBuild(
        SonarScanner.create(projectDir("shared/xoo-sample"))
            .setProperty("sonar.links.homepage", "http://example.com"));
  }
Пример #10
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);
  }
Пример #11
0
  @BeforeClass
  public static void analyzeProject() {
    orchestrator.resetData();

    orchestrator
        .getServer()
        .restoreProfile(FileLocation.ofClasspath("/authorisation/one-issue-per-line-profile.xml"));

    orchestrator.getServer().provisionProject(PROJECT_KEY, "Sample");
    orchestrator
        .getServer()
        .associateProjectToQualityProfile("sample", "xoo", "one-issue-per-line");
    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
    orchestrator.executeBuild(sampleProject);

    adminWsClient = newAdminWsClient(orchestrator);
    permissionsWsClient = adminWsClient.permissions();

    createUser(LOGIN, "George Orwell");
    createGroup(GROUP_NAME);
  }