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