use of org.sonar.scanner.bootstrap.GlobalTempFolderProvider in project sonarqube by SonarSource.
the class GlobalTempFolderProviderTest method createTempFolderDefault.
@Test
public void createTempFolderDefault() throws Exception {
System2 system = mock(System2.class);
tempFolderProvider = new GlobalTempFolderProvider(system);
File userHome = temp.newFolder();
when(system.envVariable("SONAR_USER_HOME")).thenReturn(null);
when(system.property("user.home")).thenReturn(userHome.getAbsolutePath().toString());
// if nothing is defined, it will be in {user.home}/.sonar/.sonartmp
File defaultSonarHome = new File(userHome.getAbsolutePath(), ".sonar");
File workingDir = new File(defaultSonarHome, CoreProperties.GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE).getAbsoluteFile();
try {
TempFolder tempFolder = tempFolderProvider.provide(new GlobalProperties(Collections.<String, String>emptyMap()));
tempFolder.newDir();
tempFolder.newFile();
assertThat(getCreatedTempDir(workingDir)).exists();
assertThat(getCreatedTempDir(workingDir).list()).hasSize(2);
} finally {
FileUtils.deleteQuietly(workingDir);
}
}
Aggregations