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());
}
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();
}
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));
}
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();
}
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);
}
Aggregations