Search in sources :

Example 6 with ComponentContainer

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

the class WebServicesWsModuleTest method verify_count_of_added_components.

@Test
public void verify_count_of_added_components() {
    ComponentContainer container = new ComponentContainer();
    new WebServicesWsModule().configure(container);
    assertThat(container.size()).isEqualTo(3 + 2);
}
Also used : ComponentContainer(org.sonar.core.platform.ComponentContainer) Test(org.junit.Test)

Example 7 with ComponentContainer

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

the class ScannerExtensionDictionnary method completeBatchExtensions.

private static <T> void completeBatchExtensions(ComponentContainer container, List<T> extensions, Class<T> type) {
    extensions.addAll(container.getComponentsByType(type));
    ComponentContainer parentContainer = container.getParent();
    if (parentContainer != null) {
        completeBatchExtensions(parentContainer, extensions, type);
    }
}
Also used : ComponentContainer(org.sonar.core.platform.ComponentContainer)

Example 8 with ComponentContainer

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

the class ScannerExtensionDictionnaryTest method shouldSearchInParentContainers.

@Test
public void shouldSearchInParentContainers() {
    Sensor a = new FakeSensor();
    Sensor b = new FakeSensor();
    Sensor c = new FakeSensor();
    ComponentContainer grandParent = new ComponentContainer();
    grandParent.addSingleton(a);
    ComponentContainer parent = grandParent.createChild();
    parent.addSingleton(b);
    ComponentContainer child = parent.createChild();
    child.addSingleton(c);
    ScannerExtensionDictionnary dictionnary = new ScannerExtensionDictionnary(child, mock(DefaultSensorContext.class), mock(SensorOptimizer.class), mock(PostJobContext.class), mock(PostJobOptimizer.class));
    assertThat(dictionnary.select(Sensor.class, null, true, null)).containsOnly(a, b, c);
}
Also used : SensorOptimizer(org.sonar.scanner.sensor.SensorOptimizer) PostJobContext(org.sonar.api.batch.postjob.PostJobContext) PostJobOptimizer(org.sonar.scanner.postjob.PostJobOptimizer) DefaultSensorContext(org.sonar.scanner.sensor.DefaultSensorContext) ComponentContainer(org.sonar.core.platform.ComponentContainer) Sensor(org.sonar.api.batch.Sensor) Test(org.junit.Test)

Example 9 with ComponentContainer

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

the class ExtensionInstallerTest method should_provide_list_of_extensions.

@Test
public void should_provide_list_of_extensions() {
    when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
    when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(new FooBarProvider()));
    ComponentContainer container = new ComponentContainer();
    ExtensionInstaller installer = new ExtensionInstaller(mock(SonarRuntime.class), pluginRepository, mock(AnalysisMode.class));
    installer.install(container, new TrueMatcher());
    assertThat(container.getComponentByType(Foo.class)).isNotNull();
    assertThat(container.getComponentByType(Bar.class)).isNotNull();
}
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 10 with ComponentContainer

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

the class ExtensionInstallerTest method should_filter_extensions_to_install.

@Test
public void should_filter_extensions_to_install() {
    when(pluginRepository.getPluginInfos()).thenReturn(Arrays.asList(new PluginInfo("foo")));
    when(pluginRepository.getPluginInstance("foo")).thenReturn(newPluginInstance(Foo.class, Bar.class));
    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)

Aggregations

ComponentContainer (org.sonar.core.platform.ComponentContainer)51 Test (org.junit.Test)46 SonarRuntime (org.sonar.api.SonarRuntime)3 AnalysisMode (org.sonar.api.batch.AnalysisMode)3 PluginInfo (org.sonar.core.platform.PluginInfo)3 TaskContainer (org.sonar.server.computation.task.container.TaskContainer)2 TaskContainerImpl (org.sonar.server.computation.task.container.TaskContainerImpl)2 Platform (org.sonar.server.platform.Platform)2 Before (org.junit.Before)1 Sensor (org.sonar.api.batch.Sensor)1 PostJobContext (org.sonar.api.batch.postjob.PostJobContext)1 MapSettings (org.sonar.api.config.MapSettings)1 PostJobOptimizer (org.sonar.scanner.postjob.PostJobOptimizer)1 DefaultSensorContext (org.sonar.scanner.sensor.DefaultSensorContext)1 SensorOptimizer (org.sonar.scanner.sensor.SensorOptimizer)1 ProjectsEsModule (org.sonar.server.measure.index.ProjectsEsModule)1 ServerLifecycleNotifier (org.sonar.server.platform.ServerLifecycleNotifier)1 ServerExtensionInstaller (org.sonar.server.plugins.ServerExtensionInstaller)1