Search in sources :

Example 11 with Release

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();
}
Also used : URI(java.net.URI) File(java.io.File) Release(org.sonar.updatecenter.common.Release) Plugin(org.sonar.updatecenter.common.Plugin) Test(org.junit.Test)

Example 12 with Release

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();
}
Also used : File(java.io.File) URI(java.net.URI) Release(org.sonar.updatecenter.common.Release) Plugin(org.sonar.updatecenter.common.Plugin) Test(org.junit.Test)

Example 13 with Release

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();
}
Also used : Version(org.sonar.updatecenter.common.Version) Release(org.sonar.updatecenter.common.Release) Test(org.junit.Test)

Example 14 with Release

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();
}
Also used : WsTester(org.sonar.server.ws.WsTester) Version(org.sonar.updatecenter.common.Version) Release(org.sonar.updatecenter.common.Release) Test(org.junit.Test)

Aggregations

Release (org.sonar.updatecenter.common.Release)14 Test (org.junit.Test)10 Plugin (org.sonar.updatecenter.common.Plugin)9 File (java.io.File)5 URI (java.net.URI)4 SonarException (org.sonar.api.utils.SonarException)3 Version (org.sonar.updatecenter.common.Version)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 WsTester (org.sonar.server.ws.WsTester)1 PluginUpdate (org.sonar.updatecenter.common.PluginUpdate)1 Sonar (org.sonar.updatecenter.common.Sonar)1 SonarUpdate (org.sonar.updatecenter.common.SonarUpdate)1 UpdateCenter (org.sonar.updatecenter.common.UpdateCenter)1