use of org.sonar.updatecenter.common.Release 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();
}
use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.
the class PluginDownloaderTest method download_from_file.
@Test
public void download_from_file() throws Exception {
Plugin test = Plugin.factory("test");
File file = testFolder.newFile("test-1.0.jar");
file.createNewFile();
Release test10 = new Release(test, "1.0").setDownloadUrl("file://" + separatorsToUnix(file.getCanonicalPath()));
test.addRelease(test10);
when(updateCenter.findInstallablePlugins("foo", create("1.0"))).thenReturn(newArrayList(test10));
pluginDownloader.start();
pluginDownloader.download("foo", create("1.0"));
verify(httpDownloader, never()).download(any(URI.class), any(File.class));
assertThat(pluginDownloader.hasDownloads()).isTrue();
}
use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.
the class UpdateActionTest method if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter.
@Test
public void if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter() throws Exception {
logInAsSystemAdministrator();
Version version = Version.create("1.0");
when(updateCenter.findPluginUpdates()).thenReturn(ImmutableList.of(PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), Status.COMPATIBLE)));
underTest.handle(validRequest, response);
verify(pluginDownloader).download(PLUGIN_KEY, version);
assertThat(response.outputAsString()).isEmpty();
}
use of org.sonar.updatecenter.common.Release in project sonarqube by SonarSource.
the class InstallActionTest method if_plugin_is_found_available_download_is_triggered_with_latest_version_from_updatecenter.
@Test
public void if_plugin_is_found_available_download_is_triggered_with_latest_version_from_updatecenter() throws Exception {
logInAsSystemAdministrator();
Version version = Version.create("1.0");
when(updateCenter.findAvailablePlugins()).thenReturn(ImmutableList.of(PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), PluginUpdate.Status.COMPATIBLE)));
WsTester.Result result = validRequest.execute();
verify(pluginDownloader).download(PLUGIN_KEY, version);
result.assertNoContent();
}
Aggregations