Search in sources :

Example 16 with TempFolder

use of org.sonar.api.utils.TempFolder in project sonarqube by SonarSource.

the class ComputationTempFolderProviderTest method existing_temp_dir.

@Test
public void existing_temp_dir() throws Exception {
    ServerFileSystem fs = mock(ServerFileSystem.class);
    File tmpDir = temp.newFolder();
    when(fs.getTempDir()).thenReturn(tmpDir);
    TempFolder folder = underTest.provide(fs);
    assertThat(folder).isNotNull();
    File newDir = folder.newDir();
    assertThat(newDir).exists().isDirectory();
    assertThat(newDir.getParentFile().getCanonicalPath()).startsWith(tmpDir.getCanonicalPath());
}
Also used : ServerFileSystem(org.sonar.server.platform.ServerFileSystem) TempFolder(org.sonar.api.utils.TempFolder) File(java.io.File) Test(org.junit.Test)

Example 17 with TempFolder

use of org.sonar.api.utils.TempFolder in project sonarqube by SonarSource.

the class GlobalTempFolderProviderTest method dotWorkingDir.

@Test
public void dotWorkingDir() {
    File sonarHome = temp.getRoot();
    String globalWorkDir = ".";
    ScannerProperties globalProperties = new ScannerProperties(ImmutableMap.of("sonar.userHome", sonarHome.getAbsolutePath(), CoreProperties.GLOBAL_WORKING_DIRECTORY, globalWorkDir));
    TempFolder tempFolder = tempFolderProvider.provide(globalProperties);
    File newFile = tempFolder.newFile();
    assertThat(newFile.getParentFile().getParentFile().getAbsolutePath()).isEqualTo(sonarHome.getAbsolutePath());
    assertThat(newFile.getParentFile().getName()).startsWith(".sonartmp_");
}
Also used : TempFolder(org.sonar.api.utils.TempFolder) File(java.io.File) Test(org.junit.Test)

Example 18 with TempFolder

use of org.sonar.api.utils.TempFolder in project sonarqube by SonarSource.

the class GlobalTempFolderProviderTest method createTempFolderProps.

@Test
public void createTempFolderProps() throws Exception {
    File workingDir = temp.newFolder();
    workingDir.delete();
    TempFolder tempFolder = tempFolderProvider.provide(new ScannerProperties(ImmutableMap.of(CoreProperties.GLOBAL_WORKING_DIRECTORY, workingDir.getAbsolutePath())));
    tempFolder.newDir();
    tempFolder.newFile();
    assertThat(getCreatedTempDir(workingDir)).exists();
    assertThat(getCreatedTempDir(workingDir).list()).hasSize(2);
    FileUtils.deleteQuietly(workingDir);
}
Also used : TempFolder(org.sonar.api.utils.TempFolder) File(java.io.File) Test(org.junit.Test)

Aggregations

TempFolder (org.sonar.api.utils.TempFolder)18 File (java.io.File)17 Test (org.junit.Test)16 Path (java.nio.file.Path)5 HashMap (java.util.HashMap)5 Before (org.junit.Before)5 InMemoryIssueStore (org.sonarsource.sonarlint.core.container.connected.InMemoryIssueStore)5 IssueStoreFactory (org.sonarsource.sonarlint.core.container.connected.IssueStoreFactory)5 ModuleConfigurationDownloader (org.sonarsource.sonarlint.core.container.connected.update.ModuleConfigurationDownloader)5 ModuleHierarchyDownloader (org.sonarsource.sonarlint.core.container.connected.update.ModuleHierarchyDownloader)5 ModuleQualityProfilesDownloader (org.sonarsource.sonarlint.core.container.connected.update.ModuleQualityProfilesDownloader)5 StoragePaths (org.sonarsource.sonarlint.core.container.storage.StoragePaths)5 StorageReader (org.sonarsource.sonarlint.core.container.storage.StorageReader)5 IOException (java.io.IOException)4 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 Map (java.util.Map)4 Nullable (javax.annotation.Nullable)4 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)4 Assertions.entry (org.assertj.core.api.Assertions.entry)4