Search in sources :

Example 21 with PluginInfo

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

the class PluginDownloaderTest method read_download_folder.

@Test
public void read_download_folder() throws Exception {
    pluginDownloader.start();
    assertThat(pluginDownloader.getDownloadedPluginFilenames()).hasSize(0);
    copyFileToDirectory(TestProjectUtils.jarOf("test-base-plugin"), downloadDir);
    assertThat(pluginDownloader.getDownloadedPlugins()).hasSize(1);
    PluginInfo info = pluginDownloader.getDownloadedPlugins().iterator().next();
    assertThat(info.getKey()).isEqualTo("testbase");
    assertThat(info.getName()).isEqualTo("Base Plugin");
    assertThat(info.getVersion()).isEqualTo(Version.create("0.1-SNAPSHOT"));
    assertThat(info.getMainClass()).isEqualTo("BasePlugin");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 22 with PluginInfo

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

the class InstalledActionTest method category_is_returned_when_in_additional_fields.

@Test
public void category_is_returned_when_in_additional_fields() 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()))));
    UpdateCenter updateCenter = mock(UpdateCenter.class);
    when(updateCenterMatrixFactory.getUpdateCenter(false)).thenReturn(Optional.of(updateCenter));
    when(updateCenter.findAllCompatiblePlugins()).thenReturn(Arrays.asList(Plugin.factory("plugKey").setCategory("cat_1")));
    when(request.paramAsStrings(Param.FIELDS)).thenReturn(singletonList("category"));
    underTest.handle(request, response);
    assertJson(response.outputAsString()).isSimilarTo("{" + "  \"plugins\":" + "  [" + "    {" + "      \"key\": \"plugKey\"," + "      \"name\": \"plugName\"," + "      \"description\": \"desc_it\"," + "      \"version\": \"1.0\"," + "      \"category\":\"cat_1\"," + "      \"license\": \"license_hey\"," + "      \"organizationName\": \"org_name\"," + "      \"organizationUrl\": \"org_url\"," + "      \"homepageUrl\": \"homepage_url\"," + "      \"issueTrackerUrl\": \"issueTracker_url\"," + "      \"implementationBuild\": \"sou_rev_sha1\"" + "    }" + "  ]" + "}");
}
Also used : UpdateCenter(org.sonar.updatecenter.common.UpdateCenter) PluginInfo(org.sonar.core.platform.PluginInfo) File(java.io.File) Test(org.junit.Test)

Example 23 with PluginInfo

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

the class InstalledActionTest method empty_fields_are_not_serialized_to_json.

@Test
public void empty_fields_are_not_serialized_to_json() throws Exception {
    logInAsSystemAdministrator();
    when(pluginRepository.getPluginInfos()).thenReturn(of(new PluginInfo("").setName("")));
    underTest.handle(request, response);
    assertThat(response.outputAsString()).doesNotContain("name").doesNotContain("key");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 24 with PluginInfo

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

the class GeneratePluginIndexTest method shouldWriteIndex.

@Test
public void shouldWriteIndex() throws IOException {
    PluginRepository repository = mock(PluginRepository.class);
    PluginInfo sqale = newInfo("sqale");
    PluginInfo checkstyle = newInfo("checkstyle");
    when(repository.getPluginInfos()).thenReturn(Arrays.asList(sqale, checkstyle));
    new GeneratePluginIndex(fileSystem, repository).start();
    List<String> lines = FileUtils.readLines(index);
    assertThat(lines.size(), Is.is(2));
    assertThat(lines.get(0), containsString("sqale"));
    assertThat(lines.get(1), containsString("checkstyle"));
}
Also used : PluginRepository(org.sonar.core.platform.PluginRepository) PluginInfo(org.sonar.core.platform.PluginInfo) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) Test(org.junit.Test)

Example 25 with PluginInfo

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

the class ServerPluginRepository method loadPreInstalledPlugins.

/**
   * Load the plugins that are located in extensions/plugins. Blacklisted plugins are
   * deleted.
   */
private void loadPreInstalledPlugins() {
    for (File file : listJarFiles(fs.getInstalledPluginsDir())) {
        PluginInfo info = PluginInfo.create(file);
        registerPluginInfo(info);
    }
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) PluginInfo.jarToPluginInfo(org.sonar.core.platform.PluginInfo.jarToPluginInfo) FileUtils.moveFile(org.apache.commons.io.FileUtils.moveFile) File(java.io.File) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile)

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