]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9946 Fix local copy of edition plugins for tests
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 25 Oct 2017 09:50:24 +0000 (11:50 +0200)
committerDuarte Meneses <duarte.meneses@sonarsource.com>
Wed, 25 Oct 2017 10:33:49 +0000 (12:33 +0200)
server/sonar-server/src/main/java/org/sonar/server/plugins/edition/EditionPluginDownloader.java
server/sonar-server/src/test/java/org/sonar/server/plugins/edition/EditionPluginDownloaderTest.java

index 0da1f5d7cae0b65bf57ffb831ff0dd2616f1a709..f5e73f573c9519515c30e6fe1562fce2b6e4584f 100644 (file)
@@ -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)) {
index 4f7d6498abd9cd672dbf5f757356e2ca97005879..06e0c4675a84d200db169497c99f3f58c17eeb4c 100644 (file)
@@ -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 {