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());
}
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_");
}
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);
}
Aggregations