Search in sources :

Example 11 with ProjectReactor

use of org.sonar.api.batch.bootstrap.ProjectReactor in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_load_project_root_settings_on_branch.

@Test
public void should_load_project_root_settings_on_branch() {
    project.setProperty(CoreProperties.PROJECT_BRANCH_PROPERTY, "mybranch");
    Table<String, String, String> settings = HashBasedTable.create();
    settings.put("struts:mybranch", "sonar.cpd.cross", "true");
    settings.put("struts:mybranch", "sonar.java.coveragePlugin", "jacoco");
    projectRef = new ProjectRepositories(settings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("sonar.java.coveragePlugin")).isEqualTo("jacoco");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Example 12 with ProjectReactor

use of org.sonar.api.batch.bootstrap.ProjectReactor in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_load_project_props.

@Test
public void should_load_project_props() {
    project.setProperty("project.prop", "project");
    projectRef = new ProjectRepositories(emptySettings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("project.prop")).isEqualTo("project");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Example 13 with ProjectReactor

use of org.sonar.api.batch.bootstrap.ProjectReactor in project sonarqube by SonarSource.

the class AnalysisTempFolderProviderTest method setUp.

@Before
public void setUp() {
    tempFolderProvider = new AnalysisTempFolderProvider();
    projectReactor = mock(ProjectReactor.class);
    ProjectDefinition projectDefinition = mock(ProjectDefinition.class);
    when(projectReactor.getRoot()).thenReturn(projectDefinition);
    when(projectDefinition.getWorkDir()).thenReturn(temp.getRoot());
}
Also used : AnalysisTempFolderProvider(org.sonar.scanner.analysis.AnalysisTempFolderProvider) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Before(org.junit.Before)

Example 14 with ProjectReactor

use of org.sonar.api.batch.bootstrap.ProjectReactor in project sonarqube by SonarSource.

the class ProjectSettingsTest method should_fail_when_accessing_secured_properties_in_issues_mode.

@Test
public void should_fail_when_accessing_secured_properties_in_issues_mode() {
    Table<String, String, String> settings = HashBasedTable.create();
    settings.put("struts", "sonar.foo.secured", "bar");
    settings.put("struts", "sonar.foo.license.secured", "bar2");
    when(mode.isIssues()).thenReturn(true);
    projectRef = new ProjectRepositories(settings, emptyFileData, null);
    ProjectSettings batchSettings = new ProjectSettings(new ProjectReactor(project), bootstrapProps, projectRef, mode);
    assertThat(batchSettings.getString("sonar.foo.license.secured")).isEqualTo("bar2");
    thrown.expect(MessageException.class);
    thrown.expectMessage("Access to the secured property 'sonar.foo.secured' is not possible in issues mode. The SonarQube plugin which requires this property must be deactivated in issues mode.");
    batchSettings.getString("sonar.foo.secured");
}
Also used : ProjectRepositories(org.sonar.scanner.repository.ProjectRepositories) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) Test(org.junit.Test)

Example 15 with ProjectReactor

use of org.sonar.api.batch.bootstrap.ProjectReactor in project sonarqube by SonarSource.

the class WorkDirectoryCleanerTest method setUp.

@Before
public void setUp() throws IOException {
    // create files to clean
    temp.newFile();
    File newFolder = temp.newFolder();
    File fileInFolder = new File(newFolder, "test");
    fileInFolder.createNewFile();
    File lock = new File(temp.getRoot(), DirectoryLock.LOCK_FILE_NAME);
    lock.createNewFile();
    // mock project
    ProjectReactor projectReactor = mock(ProjectReactor.class);
    ProjectDefinition projectDefinition = mock(ProjectDefinition.class);
    when(projectReactor.getRoot()).thenReturn(projectDefinition);
    when(projectDefinition.getWorkDir()).thenReturn(temp.getRoot());
    assertThat(temp.getRoot().list().length).isGreaterThan(1);
    cleaner = new WorkDirectoryCleaner(projectReactor);
}
Also used : File(java.io.File) WorkDirectoryCleaner(org.sonar.scanner.scan.WorkDirectoryCleaner) ProjectReactor(org.sonar.api.batch.bootstrap.ProjectReactor) ProjectDefinition(org.sonar.api.batch.bootstrap.ProjectDefinition) Before(org.junit.Before)

Aggregations

ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)22 Test (org.junit.Test)16 ProjectDefinition (org.sonar.api.batch.bootstrap.ProjectDefinition)5 ProjectRepositories (org.sonar.scanner.repository.ProjectRepositories)5 Before (org.junit.Before)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 File (java.io.File)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Profiler (org.sonar.api.utils.log.Profiler)1 AnalysisProperties (org.sonar.scanner.analysis.AnalysisProperties)1 AnalysisTempFolderProvider (org.sonar.scanner.analysis.AnalysisTempFolderProvider)1 DroppedPropertyChecker (org.sonar.scanner.bootstrap.DroppedPropertyChecker)1 ProjectLock (org.sonar.scanner.scan.ProjectLock)1 WorkDirectoryCleaner (org.sonar.scanner.scan.WorkDirectoryCleaner)1