use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginWSCommons method writePluginInfoList.
public void writePluginInfoList(JsonWriter json, Iterable<PluginInfo> plugins, Map<String, Plugin> compatiblePluginsByKey, String propertyName) {
json.name(propertyName);
json.beginArray();
for (PluginInfo pluginInfo : copyOf(NAME_KEY_PLUGIN_METADATA_COMPARATOR, plugins)) {
Plugin plugin = compatiblePluginsByKey.get(pluginInfo.getKey());
writePluginInfo(json, pluginInfo, categoryOrNull(plugin));
}
json.endArray();
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginWSCommons method writePluginUpdate.
public void writePluginUpdate(JsonWriter json, PluginUpdate pluginUpdate) {
Plugin plugin = pluginUpdate.getPlugin();
json.beginObject();
writePlugin(json, plugin);
writeRelease(json, pluginUpdate.getRelease());
writeUpdate(json, pluginUpdate);
json.endObject();
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginDownloaderTest method throw_exception_if_could_not_download.
@Test
public void throw_exception_if_could_not_download() {
Plugin test = Plugin.factory("test");
Release test10 = new Release(test, "1.0").setDownloadUrl("file://not_found");
test.addRelease(test10);
when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
pluginDownloader.start();
try {
pluginDownloader.download("foo", create("1.0"));
fail();
} catch (SonarException e) {
// ok
}
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginDownloaderTest method throw_exception_if_download_fail.
@Test
public void throw_exception_if_download_fail() {
Plugin test = Plugin.factory("test");
Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar");
test.addRelease(test10);
when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
doThrow(new RuntimeException()).when(httpDownloader).download(any(URI.class), any(File.class));
pluginDownloader.start();
try {
pluginDownloader.download("foo", create("1.0"));
fail();
} catch (SonarException e) {
// ok
}
}
use of org.sonar.updatecenter.common.Plugin in project sonarqube by SonarSource.
the class PluginDownloaderTest method download_from_url.
@Test
public void download_from_url() {
Plugin test = Plugin.factory("test");
Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.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("test-1.0.jar.tmp")));
assertThat(new File(downloadDir, "test-1.0.jar")).exists();
assertThat(new File(downloadDir, "test-1.0.jar.tmp")).doesNotExist();
}
Aggregations