use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginDownloaderTest method download_from_redirect_url.
/**
* SONAR-4685
*/
@Test
public void download_from_redirect_url() {
Plugin test = Plugin.factory("plugintest");
Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/redirect?r=release&g=test&a=test&v=1.0&e=jar");
test.addRelease(test10);
when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
pluginDownloader.start();
pluginDownloader.download("foo", create("1.0"));
// SONAR-4523: do not corrupt JAR files when restarting the server while a plugin is being downloaded.
// The JAR file is downloaded in a temp file
verify(httpDownloader).download(any(URI.class), argThat(new HasFileName("plugintest-1.0.jar.tmp")));
assertThat(new File(downloadDir, "plugintest-1.0.jar")).exists();
assertThat(new File(downloadDir, "plugintest-1.0.jar.tmp")).doesNotExist();
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginDownloaderTest method download_common_transitive_dependency.
// SONAR-5011
@Test
public void download_common_transitive_dependency() {
Plugin test1 = Plugin.factory("test1");
Release test1R = new Release(test1, "1.0").setDownloadUrl("http://server/test1-1.0.jar");
test1.addRelease(test1R);
Plugin test2 = Plugin.factory("test2");
Release test2R = new Release(test2, "1.0").setDownloadUrl("http://server/test2-1.0.jar");
test2.addRelease(test2R);
Plugin testDep = Plugin.factory("testdep");
Release testDepR = new Release(testDep, "1.0").setDownloadUrl("http://server/testdep-1.0.jar");
testDep.addRelease(testDepR);
when(updateCenter.findInstallablePlugins("test1", create("1.0"))).thenReturn(newArrayList(test1R, testDepR));
when(updateCenter.findInstallablePlugins("test2", create("1.0"))).thenReturn(newArrayList(test2R, testDepR));
pluginDownloader.start();
pluginDownloader.download("test1", create("1.0"));
pluginDownloader.download("test2", create("1.0"));
assertThat(new File(downloadDir, "test1-1.0.jar")).exists();
assertThat(new File(downloadDir, "test2-1.0.jar")).exists();
assertThat(new File(downloadDir, "testdep-1.0.jar")).exists();
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginDownloaderTest method download_when_update_center_is_unavailable_with_no_exception_thrown.
@Test
public void download_when_update_center_is_unavailable_with_no_exception_thrown() {
when(updateCenterMatrixFactory.getUpdateCenter(anyBoolean())).thenReturn(Optional.<UpdateCenter>absent());
Plugin test = Plugin.factory("test");
Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
test.addRelease(test10);
pluginDownloader.start();
pluginDownloader.download("foo", create("1.0"));
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PendingActionTest method newUpdateCenter.
private UpdateCenter newUpdateCenter(String... pluginKeys) {
UpdateCenter updateCenter = mock(UpdateCenter.class);
when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
List<Plugin> plugins = new ArrayList<>();
for (String pluginKey : pluginKeys) {
plugins.add(Plugin.factory(pluginKey).setCategory("cat_1"));
}
when(updateCenter.findAllCompatiblePlugins()).thenReturn(plugins);
return updateCenter;
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PendingAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkIsSystemAdministrator();
ImmutableMap<String, Plugin> compatiblePluginsByKey = compatiblePluginsByKey(updateCenterMatrixFactory);
JsonWriter jsonWriter = response.newJsonWriter();
jsonWriter.beginObject();
writePlugins(jsonWriter, compatiblePluginsByKey);
jsonWriter.endObject();
jsonWriter.close();
}
Aggregations