Search in sources :

Example 1 with SpringComponentContainer

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

the class TaskContainerImplTest method constructor_fails_fast_on_null_item.

@Test
public void constructor_fails_fast_on_null_item() {
    SpringComponentContainer c = new SpringComponentContainer();
    assertThatThrownBy(() -> new TaskContainerImpl(c, null)).isInstanceOf(NullPointerException.class);
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) Test(org.junit.Test)

Example 2 with SpringComponentContainer

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

the class ComputeEngineContainerImpl method startupTasks.

private void startupTasks() {
    SpringComponentContainer startupLevel = this.level4.createChild();
    startupLevel.add(startupComponents());
    startupLevel.startComponents();
    // done in PlatformLevelStartup
    ServerLifecycleNotifier serverLifecycleNotifier = startupLevel.getComponentByType(ServerLifecycleNotifier.class);
    if (serverLifecycleNotifier != null) {
        serverLifecycleNotifier.notifyStart();
    }
    startupLevel.stopComponents();
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) ServerLifecycleNotifier(org.sonar.server.platform.ServerLifecycleNotifier)

Example 3 with SpringComponentContainer

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

the class SQDatabase method executeDbMigrations.

private void executeDbMigrations(NoopDatabase noopDatabase) {
    SpringComponentContainer container = new SpringComponentContainer();
    container.add(noopDatabase);
    MigrationConfigurationModule migrationConfigurationModule = new MigrationConfigurationModule();
    migrationConfigurationModule.configure(container);
    // dependencies required by DB migrations
    container.add(SonarRuntimeImpl.forSonarQube(Version.create(8, 0), SonarQubeSide.SERVER, SonarEdition.COMMUNITY));
    container.add(UuidFactoryFast.getInstance());
    container.add(System2.INSTANCE);
    container.add(MapSettings.class);
    container.startComponents();
    MigrationContainer migrationContainer = new MigrationContainerImpl(container, H2StepExecutor.class);
    MigrationSteps migrationSteps = migrationContainer.getComponentByType(MigrationSteps.class);
    MigrationStepsExecutor executor = migrationContainer.getComponentByType(MigrationStepsExecutor.class);
    executor.execute(migrationSteps.readAll());
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) MigrationContainer(org.sonar.server.platform.db.migration.engine.MigrationContainer) MigrationConfigurationModule(org.sonar.server.platform.db.migration.MigrationConfigurationModule) MigrationStepsExecutor(org.sonar.server.platform.db.migration.step.MigrationStepsExecutor) MigrationContainerImpl(org.sonar.server.platform.db.migration.engine.MigrationContainerImpl) MigrationSteps(org.sonar.server.platform.db.migration.step.MigrationSteps)

Example 4 with SpringComponentContainer

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

the class NodeHealthModuleTest method no_broken_dependencies.

@Test
public void no_broken_dependencies() {
    SpringComponentContainer container = new SpringComponentContainer();
    Server server = mock(Server.class);
    NetworkUtils networkUtils = mock(NetworkUtils.class);
    // settings required by NodeHealthProvider
    mapSettings.setProperty("sonar.cluster.node.name", randomAlphanumeric(3));
    mapSettings.setProperty("sonar.cluster.node.port", valueOf(1 + random.nextInt(10)));
    when(server.getStartedAt()).thenReturn(new Date());
    when(networkUtils.getHostname()).thenReturn(randomAlphanumeric(12));
    // upper level dependencies
    container.add(mock(System2.class), mapSettings.asConfig(), server, networkUtils, mock(HazelcastMember.class));
    // HealthAction dependencies
    container.add(mock(HealthChecker.class));
    underTest.configure(container);
    container.startComponents();
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) Server(org.sonar.api.platform.Server) NetworkUtils(org.sonar.process.NetworkUtils) System2(org.sonar.api.utils.System2) HazelcastMember(org.sonar.process.cluster.hz.HazelcastMember) Date(java.util.Date) Test(org.junit.Test)

Example 5 with SpringComponentContainer

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

the class ReportComputationStepsTest method instances_throws_ISE_if_container_does_not_have_second_step.

@Test
public void instances_throws_ISE_if_container_does_not_have_second_step() {
    ExtractReportStep reportExtractionStep = mock(ExtractReportStep.class);
    SpringComponentContainer componentContainer = new SpringComponentContainer() {

        {
            add(reportExtractionStep);
        }
    }.startComponents();
    TaskContainerImpl computeEngineContainer = new TaskContainerImpl(componentContainer, container -> {
    // do nothing
    });
    computeEngineContainer.startComponents();
    Iterable<ComputationStep> instances = new ReportComputationSteps(computeEngineContainer).instances();
    assertThatThrownBy(() -> newArrayList(instances)).isInstanceOf(IllegalStateException.class).hasMessageContaining("org.sonar.ce.task.projectanalysis.step.PersistScannerContextStep");
}
Also used : SpringComponentContainer(org.sonar.core.platform.SpringComponentContainer) TaskContainerImpl(org.sonar.ce.task.container.TaskContainerImpl) ComputationStep(org.sonar.ce.task.step.ComputationStep) Test(org.junit.Test)

Aggregations

SpringComponentContainer (org.sonar.core.platform.SpringComponentContainer)11 Test (org.junit.Test)5 TaskContainerImpl (org.sonar.ce.task.container.TaskContainerImpl)3 ComputationStep (org.sonar.ce.task.step.ComputationStep)3 CoreExtensionsInstaller (org.sonar.core.extension.CoreExtensionsInstaller)3 WebCoreExtensionsInstaller (org.sonar.server.platform.WebCoreExtensionsInstaller)3 Date (java.util.Date)1 Server (org.sonar.api.platform.Server)1 System2 (org.sonar.api.utils.System2)1 ComplexityMeasuresStep (org.sonar.ce.task.projectanalysis.step.ComplexityMeasuresStep)1 NetworkUtils (org.sonar.process.NetworkUtils)1 HazelcastMember (org.sonar.process.cluster.hz.HazelcastMember)1 ServerLifecycleNotifier (org.sonar.server.platform.ServerLifecycleNotifier)1 MigrationConfigurationModule (org.sonar.server.platform.db.migration.MigrationConfigurationModule)1 MigrationContainer (org.sonar.server.platform.db.migration.engine.MigrationContainer)1 MigrationContainerImpl (org.sonar.server.platform.db.migration.engine.MigrationContainerImpl)1 MigrationSteps (org.sonar.server.platform.db.migration.step.MigrationSteps)1 MigrationStepsExecutor (org.sonar.server.platform.db.migration.step.MigrationStepsExecutor)1 ServerExtensionInstaller (org.sonar.server.plugins.ServerExtensionInstaller)1