aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-10-25 11:50:24 +0200
committerDuarte Meneses <duarte.meneses@sonarsource.com>2017-10-25 12:33:49 +0200
commitb0deb0d52985ce94e4afe28f4378f14e4dae4713 (patch)
tree671665833afae8f87a64bbb6dc5016a713de623d /server
parent1a43ec857f409085f2a6076a49e1d7a822ad43db (diff)
downloadsonarqube-b0deb0d52985ce94e4afe28f4378f14e4dae4713.tar.gz
sonarqube-b0deb0d52985ce94e4afe28f4378f14e4dae4713.zip
SONAR-9946 Fix local copy of edition plugins for tests
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java2
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java16
2 files changed, 17 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
index 0da1f5d7cae..f5e73f573c9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
@@ -95,7 +95,7 @@ public class EditionPluginDownloader {
if (url.startsWith("file:")) {
// used for tests
File file = toFile(uri.toURL());
- Files.copy(file.toPath(), tmpDir);
+ Files.copy(file.toPath(), tmpDir.resolve(file.getName()));
} else {
String filename = substringAfterLast(uri.getPath(), "/");
if (!filename.endsWith("." + PLUGIN_EXTENSION)) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java
index 4f7d6498abd..06e0c4675a8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java
@@ -83,6 +83,22 @@ public class EditionPluginDownloaderTest {
assertThat(downloadDir).isDirectory();
assertThat(tmpDir).doesNotExist();
}
+
+ @Test
+ public void download_plugin_to_tmp_with_file_uri() throws IOException, URISyntaxException {
+ File plugin1 = temp.newFile("plugin1.jar");
+ File plugin2 = temp.newFile("plugin2.jar");
+
+ List<Release> releases = ImmutableList.of(createRelease("plugin1", "1.0", plugin1.toURI().toString()),
+ createRelease("plugin2", "1.0", plugin2.toURI().toString()));
+
+ when(updateCenter.findInstallablePlugins("plugins", Version.create(""))).thenReturn(releases);
+ downloader.downloadEditionPlugins(Collections.singleton("plugins"), updateCenter);
+
+ assertThat(logTester.logs()).containsOnly("Downloading plugin: plugin1", "Downloading plugin: plugin2");
+ assertThat(downloadDir).isDirectory();
+ assertThat(tmpDir).doesNotExist();
+ }
@Test
public void dont_write_download_dir_if_download_fails() throws URISyntaxException {