Search in sources :

Example 6 with TempFolder

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

the class GlobalTempFolderProviderTest method dotWorkingDir.

@Test
public void dotWorkingDir() throws IOException {
    File sonarHome = temp.getRoot();
    String globalWorkDir = ".";
    GlobalProperties globalProperties = new GlobalProperties(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 : GlobalProperties(org.sonar.scanner.bootstrap.GlobalProperties) TempFolder(org.sonar.api.utils.TempFolder) File(java.io.File) Test(org.junit.Test)

Example 7 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();
    TempFolder tempFolder = tempFolderProvider.provide(new GlobalProperties(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 : GlobalProperties(org.sonar.scanner.bootstrap.GlobalProperties) TempFolder(org.sonar.api.utils.TempFolder) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)7 Test (org.junit.Test)7 TempFolder (org.sonar.api.utils.TempFolder)7 GlobalProperties (org.sonar.scanner.bootstrap.GlobalProperties)4 System2 (org.sonar.api.utils.System2)1 GlobalTempFolderProvider (org.sonar.scanner.bootstrap.GlobalTempFolderProvider)1