Search in sources :

Example 36 with PluginInfo

use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.

the class PluginsMonitorTest method plugin_name_and_version.

@Test
public void plugin_name_and_version() {
    when(repo.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("key-1").setName("plugin-1").setVersion(Version.create("1.1")), new PluginInfo("key-2").setName("plugin-2").setVersion(Version.create("2.2")), new PluginInfo("no-version").setName("No Version")));
    Map<String, Object> attributes = underTest.attributes();
    assertThat(attributes).containsKeys("key-1", "key-2");
    assertThat((Map) attributes.get("key-1")).containsEntry("Name", "plugin-1").containsEntry("Version", "1.1");
    assertThat((Map) attributes.get("key-2")).containsEntry("Name", "plugin-2").containsEntry("Version", "2.2");
    assertThat((Map) attributes.get("no-version")).containsEntry("Name", "No Version").doesNotContainKey("Version");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 37 with PluginInfo

use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.

the class InstalledActionTest method verify_properties_displayed_in_json_per_plugin.

@Test
public void verify_properties_displayed_in_json_per_plugin() throws Exception {
    logInAsSystemAdministrator();
    String jarFilename = getClass().getSimpleName() + "/" + "some.jar";
    when(pluginRepository.getPluginInfos()).thenReturn(of(new PluginInfo("plugKey").setName("plugName").setDescription("desc_it").setVersion(Version.create("1.0")).setLicense("license_hey").setOrganizationName("org_name").setOrganizationUrl("org_url").setHomepageUrl("homepage_url").setIssueTrackerUrl("issueTracker_url").setImplementationBuild("sou_rev_sha1").setJarFile(new File(getClass().getResource(jarFilename).toURI()))));
    underTest.handle(request, response);
    verifyZeroInteractions(updateCenterMatrixFactory);
    assertJson(response.outputAsString()).isSimilarTo("{" + "  \"plugins\":" + "  [" + "    {" + "      \"key\": \"plugKey\"," + "      \"name\": \"plugName\"," + "      \"description\": \"desc_it\"," + "      \"version\": \"1.0\"," + "      \"license\": \"license_hey\"," + "      \"organizationName\": \"org_name\"," + "      \"organizationUrl\": \"org_url\"," + "      \"homepageUrl\": \"homepage_url\"," + "      \"issueTrackerUrl\": \"issueTracker_url\"," + "      \"implementationBuild\": \"sou_rev_sha1\"" + "    }" + "  ]" + "}");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) File(java.io.File) Test(org.junit.Test)

Example 38 with PluginInfo

use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.

the class PendingActionTest method verify_properties_displayed_in_json_per_installing_removing_and_updating_plugins.

@Test
public void verify_properties_displayed_in_json_per_installing_removing_and_updating_plugins() throws Exception {
    logInAsSystemAdministrator();
    PluginInfo installed = newPluginInfo("java");
    PluginInfo removedPlugin = newPluginInfo("js");
    PluginInfo newPlugin = newPluginInfo("php");
    newUpdateCenter("scmgit");
    when(serverPluginRepository.getPluginInfos()).thenReturn(of(installed));
    when(serverPluginRepository.getUninstalledPlugins()).thenReturn(of(removedPlugin));
    when(pluginDownloader.getDownloadedPlugins()).thenReturn(of(newPlugin, installed));
    underTest.handle(request, response);
    assertJson(response.outputAsString()).isSimilarTo("{" + "  \"installing\":" + "  [" + "    {" + "      \"key\": \"php\"" + "    }" + "  ]," + "  \"removing\":" + "  [" + "    {" + "      \"key\": \"js\"" + "    }" + "  ]," + "  \"updating\": " + "  [" + "    {" + "      \"key\": \"java\"" + "    }" + "  ]" + "}");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 39 with PluginInfo

use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.

the class CePluginRepository method getPluginInfo.

@Override
public PluginInfo getPluginInfo(String key) {
    checkState(started.get(), NOT_STARTED_YET);
    PluginInfo info = pluginInfosByKeys.get(key);
    if (info == null) {
        throw new IllegalArgumentException(format("Plugin [%s] does not exist", key));
    }
    return info;
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo)

Example 40 with PluginInfo

use of org.sonar.core.platform.PluginInfo in project sonarqube by SonarSource.

the class CePluginJarExploderTest method plugins_do_not_overlap.

@Test
public void plugins_do_not_overlap() throws Exception {
    PluginInfo info1 = PluginInfo.create(plugin1Jar());
    PluginInfo info2 = PluginInfo.create(plugin2Jar());
    ExplodedPlugin exploded1 = underTest.explode(info1);
    ExplodedPlugin exploded2 = underTest.explode(info2);
    assertThat(exploded1.getKey()).isEqualTo("test");
    assertThat(exploded1.getMain()).isFile().exists().hasName("sonar-test-plugin-0.1-SNAPSHOT.jar");
    assertThat(exploded2.getKey()).isEqualTo("test2");
    assertThat(exploded2.getMain()).isFile().exists().hasName("sonar-test2-plugin-0.1-SNAPSHOT.jar");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) ExplodedPlugin(org.sonar.core.platform.ExplodedPlugin) Test(org.junit.Test)

Aggregations

PluginInfo (org.sonar.core.platform.PluginInfo)50 Test (org.junit.Test)23 File (java.io.File)9 Plugin (org.sonar.api.Plugin)7 PluginInfo.jarToPluginInfo (org.sonar.core.platform.PluginInfo.jarToPluginInfo)7 PluginRepository (org.sonar.core.platform.PluginRepository)5 ExplodedPlugin (org.sonar.core.platform.ExplodedPlugin)4 FileUtils.copyFile (org.apache.commons.io.FileUtils.copyFile)3 FileUtils.moveFile (org.apache.commons.io.FileUtils.moveFile)3 SonarRuntime (org.sonar.api.SonarRuntime)3 AnalysisMode (org.sonar.api.batch.AnalysisMode)3 ComponentContainer (org.sonar.core.platform.ComponentContainer)3 Version (org.sonar.updatecenter.common.Version)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Before (org.junit.Before)2 ExtensionProvider (org.sonar.api.ExtensionProvider)2 JsonWriter (org.sonar.api.utils.text.JsonWriter)2