Search in sources :

Example 46 with PluginInfo

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

the class DefaultI18nTest method before.

@Before
public void before() {
    PluginRepository pluginRepository = mock(PluginRepository.class);
    List<PluginInfo> plugins = Arrays.asList(newPlugin("sqale"), newPlugin("frpack"), newPlugin("checkstyle"), newPlugin("other"));
    when(pluginRepository.getPluginInfos()).thenReturn(plugins);
    underTest = new DefaultI18n(pluginRepository, system2);
    underTest.doStart(getClass().getClassLoader());
}
Also used : PluginRepository(org.sonar.core.platform.PluginRepository) PluginInfo(org.sonar.core.platform.PluginInfo) Before(org.junit.Before)

Example 47 with PluginInfo

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

the class ScannerPluginRepository method start.

@Override
public void start() {
    infosByKeys = new HashMap<>(installer.installRemotes());
    pluginInstancesByKeys = new HashMap<>(loader.load(infosByKeys));
    // this part is only used by tests
    for (Map.Entry<String, Plugin> entry : installer.installLocals().entrySet()) {
        String pluginKey = entry.getKey();
        PluginInfo pluginInfo = new PluginInfo(pluginKey);
        infosByKeys.put(pluginKey, pluginInfo);
        pluginInstancesByKeys.put(pluginKey, entry.getValue());
    }
    keysByClassLoader = new HashMap<>();
    for (Map.Entry<String, Plugin> e : pluginInstancesByKeys.entrySet()) {
        keysByClassLoader.put(e.getValue().getClass().getClassLoader(), e.getKey());
    }
    logPlugins();
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Map(java.util.Map) HashMap(java.util.HashMap) Plugin(org.sonar.api.Plugin)

Example 48 with PluginInfo

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

the class ScannerPluginRepositoryTest method install_and_load_plugins.

@Test
public void install_and_load_plugins() {
    PluginInfo info = new PluginInfo("squid");
    ImmutableMap<String, PluginInfo> infos = ImmutableMap.of("squid", info);
    Plugin instance = mock(Plugin.class);
    when(loader.load(infos)).thenReturn(ImmutableMap.of("squid", instance));
    when(installer.installRemotes()).thenReturn(infos);
    underTest.start();
    assertThat(underTest.getPluginInfos()).containsOnly(info);
    assertThat(underTest.getPluginInfo("squid")).isSameAs(info);
    assertThat(underTest.getPluginInstance("squid")).isSameAs(instance);
    underTest.stop();
    verify(loader).unload(anyCollectionOf(Plugin.class));
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) Plugin(org.sonar.api.Plugin) Test(org.junit.Test)

Example 49 with PluginInfo

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

the class ExtensionInstallerTest method should_execute_extension_provider.

@Test
public void should_execute_extension_provider() {
    when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
    when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooProvider(), new BarProvider()));
    ComponentContainer container = new ComponentContainer();
    ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, mock(AnalysisMode.class));
    installer.install(container, new FooMatcher());
    assertThat(container.getComponentByType(Foo.class)).isNotNull();
    assertThat(container.getComponentByType(Bar.class)).isNull();
}
Also used : ComponentContainer(org.sonar.core.platform.ComponentContainer) PluginInfo(org.sonar.core.platform.PluginInfo) SonarRuntime(org.sonar.api.SonarRuntime) AnalysisMode(org.sonar.api.batch.AnalysisMode) Test(org.junit.Test)

Example 50 with PluginInfo

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

the class AnalysisContextReportPublisherTest method shouldOnlyDumpPluginsByDefault.

@Test
public void shouldOnlyDumpPluginsByDefault() throws Exception {
    when(pluginRepo.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("xoo").setName("Xoo").setVersion(Version.create("1.0"))));
    ScannerReportWriter writer = new ScannerReportWriter(temp.newFolder());
    publisher.init(writer);
    assertThat(writer.getFileStructure().analysisLog()).exists();
    assertThat(FileUtils.readFileToString(writer.getFileStructure().analysisLog())).contains("Xoo 1.0 (xoo)");
    verifyZeroInteractions(system2);
}
Also used : PluginInfo(org.sonar.core.platform.PluginInfo) ScannerReportWriter(org.sonar.scanner.protocol.output.ScannerReportWriter) 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