aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/test/java
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2017-08-07 16:22:59 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2017-09-07 08:33:31 +0200
commit82b2e9e5c327119ede2ee66cd63c65722b40409c (patch)
tree51b4f092485d8398d75503e9c31c40ceccea89f8 /sonar-scanner-engine/src/test/java
parent5312732c79afcddb26b81e6be4278279f186cc22 (diff)
downloadsonarqube-82b2e9e5c327119ede2ee66cd63c65722b40409c.tar.gz
sonarqube-82b2e9e5c327119ede2ee66cd63c65722b40409c.zip
SONAR-9684 Use api/plugins/installed to load plugins
Diffstat (limited to 'sonar-scanner-engine/src/test/java')
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginInstallerTest.java20
1 files changed, 12 insertions, 8 deletions
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginInstallerTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginInstallerTest.java
index ebbfecb79d7..580ccd31c21 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginInstallerTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/bootstrap/ScannerPluginInstallerTest.java
@@ -20,16 +20,16 @@
package org.sonar.scanner.bootstrap;
import java.io.File;
-import java.io.StringReader;
-import java.util.List;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
-import org.sonar.core.platform.RemotePlugin;
import org.sonar.home.cache.FileCache;
import org.sonar.scanner.WsTestUtil;
+import org.sonar.scanner.bootstrap.ScannerPluginInstaller.InstalledPlugin;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
@@ -56,11 +56,12 @@ public class ScannerPluginInstallerTest {
@Test
public void listRemotePlugins() {
- WsTestUtil.mockReader(wsClient, "/deploy/plugins/index.txt", new StringReader("checkstyle\nsqale"));
+ WsTestUtil.mockReader(wsClient, "/api/plugins/installed",
+ new InputStreamReader(this.getClass().getResourceAsStream("ScannerPluginInstallerTest/installed-plugins-ws.json"), StandardCharsets.UTF_8));
ScannerPluginInstaller underTest = new ScannerPluginInstaller(wsClient, fileCache, pluginPredicate);
- List<RemotePlugin> remotePlugins = underTest.listRemotePlugins();
- assertThat(remotePlugins).extracting("key").containsOnly("checkstyle", "sqale");
+ InstalledPlugin[] remotePlugins = underTest.listInstalledPlugins();
+ assertThat(remotePlugins).extracting("key").containsOnly("scmgit", "java", "scmsvn");
}
@Test
@@ -70,7 +71,10 @@ public class ScannerPluginInstallerTest {
ScannerPluginInstaller underTest = new ScannerPluginInstaller(wsClient, fileCache, pluginPredicate);
- RemotePlugin remote = new RemotePlugin("checkstyle").setFile("checkstyle-plugin.jar", "fakemd5_1");
+ InstalledPlugin remote = new InstalledPlugin();
+ remote.key = "checkstyle";
+ remote.filename = "checkstyle-plugin.jar";
+ remote.hash = "fakemd5_1";
File file = underTest.download(remote);
assertThat(file).isEqualTo(pluginJar);
@@ -78,7 +82,7 @@ public class ScannerPluginInstallerTest {
@Test
public void should_fail_to_get_plugin_index() {
- WsTestUtil.mockException(wsClient, "/deploy/plugins/index.txt", new IllegalStateException());
+ WsTestUtil.mockException(wsClient, "/api/plugins/installed", new IllegalStateException());
thrown.expect(IllegalStateException.class);
new ScannerPluginInstaller(wsClient, fileCache, pluginPredicate).installRemotes();