Search in sources :

Example 31 with PluginInfo

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

the class ServerPluginJarExploderTest method copy_all_classloader_files_to_dedicated_directory.

@Test
public void copy_all_classloader_files_to_dedicated_directory() throws Exception {
    File deployDir = temp.newFolder();
    when(fs.getDeployedPluginsDir()).thenReturn(deployDir);
    File jar = TestProjectUtils.jarOf("test-libs-plugin");
    PluginInfo info = PluginInfo.create(jar);
    ExplodedPlugin exploded = underTest.explode(info);
    // all the files loaded by classloaders (JAR + META-INF/libs/*.jar) are copied to the dedicated directory
    // web/deploy/{pluginKey}
    File pluginDeployDir = new File(deployDir, "testlibs");
    assertThat(exploded.getKey()).isEqualTo("testlibs");
    assertThat(exploded.getMain()).isFile().exists().hasParent(pluginDeployDir);
    assertThat(exploded.getLibs()).extracting("name").containsOnly("commons-daemon-1.0.15.jar", "commons-email-20030310.165926.jar");
    for (File lib : exploded.getLibs()) {
        assertThat(lib).exists().isFile();
        assertThat(lib.getCanonicalPath()).startsWith(pluginDeployDir.getCanonicalPath());
    }
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) File(java.io.File) ExplodedPlugin(org.sonar.core.platform.ExplodedPlugin) Test(org.junit.Test)

Example 32 with PluginInfo

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

the class ServerPluginRepositoryTest method plugin_is_compatible_if_no_entry_point_class_but_extend_other_plugin.

/**
   * Some plugins can only extend the classloader of base plugin, without declaring new extensions.
   */
@Test
public void plugin_is_compatible_if_no_entry_point_class_but_extend_other_plugin() {
    PluginInfo basePlugin = new PluginInfo("base").setMainClass("org.bar.Bar");
    PluginInfo plugin = new PluginInfo("foo").setBasePlugin("base");
    Map<String, PluginInfo> plugins = ImmutableMap.of("base", basePlugin, "foo", plugin);
    assertThat(ServerPluginRepository.isCompatible(plugin, runtime, plugins)).isTrue();
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 33 with PluginInfo

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

the class ServerPluginRepositoryTest method plugin_is_incompatible_if_no_entry_point_class.

@Test
public void plugin_is_incompatible_if_no_entry_point_class() {
    PluginInfo plugin = new PluginInfo("foo").setName("Foo");
    assertThat(ServerPluginRepository.isCompatible(plugin, runtime, Collections.emptyMap())).isFalse();
    assertThat(logs.logs()).contains("Plugin Foo [foo] is ignored because entry point class is not defined");
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 34 with PluginInfo

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

the class InstalledPluginReferentialFactoryTest method should_create_plugin_referential.

@Test
public void should_create_plugin_referential() {
    PluginInfo info = new PluginInfo("foo");
    PluginRepository pluginRepository = mock(PluginRepository.class);
    when(pluginRepository.getPluginInfos()).thenReturn(newArrayList(info));
    InstalledPluginReferentialFactory factory = new InstalledPluginReferentialFactory(pluginRepository);
    assertThat(factory.getInstalledPluginReferential()).isNull();
    factory.start();
    assertThat(factory.getInstalledPluginReferential()).isNotNull();
    assertThat(factory.getInstalledPluginReferential().getPlugins()).hasSize(1);
}
Also used : PluginRepository(org.sonar.core.platform.PluginRepository) PluginInfo(org.sonar.core.platform.PluginInfo) Test(org.junit.Test)

Example 35 with PluginInfo

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

the class PluginReferentialMetadataConverterTest method should_convert_info_to_plugin_referential.

@Test
public void should_convert_info_to_plugin_referential() {
    PluginInfo info = new PluginInfo("foo");
    PluginReferential pluginReferential = PluginReferentialMetadataConverter.getInstalledPluginReferential(newArrayList(info));
    assertThat(pluginReferential).isNotNull();
    assertThat(pluginReferential.getPlugins()).hasSize(1);
    assertThat(pluginReferential.getPlugins().get(0).getKey()).isEqualTo("foo");
}
Also used : PluginReferential(org.sonar.updatecenter.common.PluginReferential) PluginInfo(org.sonar.core.platform.PluginInfo) 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