From 045a34deadfa9e0aed6d1dc3cc0059f3e0b390ad Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 30 Apr 2018 22:53:02 +0200 Subject: SONAR-10591 Remove unused code in sonar-home --- .../main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java | 5 ++++- .../org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'sonar-scanner-engine') diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java index b2946c96071..7deea6e36d6 100644 --- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java +++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/bootstrap/FileCacheProvider.java @@ -19,6 +19,7 @@ */ package org.sonar.scanner.bootstrap; +import java.io.File; import org.picocontainer.injectors.ProviderAdapter; import org.sonar.api.config.Configuration; import org.sonar.home.cache.FileCache; @@ -29,7 +30,9 @@ public class FileCacheProvider extends ProviderAdapter { public FileCache provide(Configuration settings) { if (cache == null) { - String home = settings.get("sonar.userHome").orElse(null); + File home = settings.get("sonar.userHome") + .map(File::new) + .orElse(null); cache = new FileCacheBuilder(new Slf4jLogger()).setUserHome(home).build(); } return cache; diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java index 00e7bdfc398..c8a92c3a3ca 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginJarExploderTest.java @@ -38,8 +38,8 @@ public class ScannerPluginJarExploderTest { @ClassRule public static TemporaryFolder temp = new TemporaryFolder(); - File userHome; - ScannerPluginJarExploder underTest; + private File userHome; + private ScannerPluginJarExploder underTest; @Before public void setUp() throws IOException { @@ -55,7 +55,7 @@ public class ScannerPluginJarExploderTest { assertThat(exploded.getKey()).isEqualTo("checkstyle"); assertThat(exploded.getMain()).isFile().exists(); - assertThat(exploded.getLibs()).extracting("name").containsOnly("antlr-2.7.6.jar", "checkstyle-5.1.jar", "commons-cli-1.0.jar"); + assertThat(exploded.getLibs()).extracting(File::getName).containsExactlyInAnyOrder("antlr-2.7.6.jar", "checkstyle-5.1.jar", "commons-cli-1.0.jar"); assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar")).exists(); assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/META-INF/lib/checkstyle-5.1.jar")).exists(); } @@ -70,7 +70,7 @@ public class ScannerPluginJarExploderTest { assertThat(new File(fileFromCache.getParent(), "sonar-checkstyle-plugin-2.8.jar_unzip/org/sonar/plugins/checkstyle/CheckstyleVersion.class")).doesNotExist(); } - File getFileFromCache(String filename) throws IOException { + private File getFileFromCache(String filename) throws IOException { File src = FileUtils.toFile(getClass().getResource(this.getClass().getSimpleName() + "/" + filename)); File destFile = new File(new File(userHome, "" + filename.hashCode()), filename); FileUtils.copyFile(src, destFile); -- cgit v1.2.3