Package org.sonar.api.platform

Examples of org.sonar.api.platform.ComponentContainer


  }

  @Test
  public void should_enable_all_phases() {
    ScanTask task = new ScanTask(mock(TaskContainer.class));
    ComponentContainer projectScanContainer = new ComponentContainer();
    projectScanContainer.add(mock(ProjectConfigurator.class), new ProjectReactor(ProjectDefinition.create().setProperty(CoreProperties.PROJECT_KEY_PROPERTY, "foo")),
      mock(Settings.class),
      mock(ResourceDao.class));
    task.scan(projectScanContainer);

    Phases phases = projectScanContainer.getComponentByType(Phases.class);
    assertThat(phases.isFullyEnabled()).isTrue();
  }
View Full Code Here


  public void prepare() {
    projectBootstrapper = mock(ProjectBootstrapper.class);
    bootstrapProperties = new BootstrapProperties(Collections.<String, String>emptyMap());
    AnalysisMode analysisMode = new AnalysisMode(bootstrapProperties);
    when(projectBootstrapper.bootstrap()).thenReturn(new ProjectReactor(ProjectDefinition.create()));
    parentContainer = new ComponentContainer();
    parentContainer.add(System2.INSTANCE);
    parentContainer.add(bootstrapProperties);
    parentContainer.add(analysisMode);
    GlobalReferentials globalRef = new GlobalReferentials();
    settings = new GlobalSettings(bootstrapProperties, new PropertyDefinitions(), globalRef, analysisMode);
View Full Code Here

  void addComponents(Collection components) {
    this.level4AddedComponents.addAll(components);
  }

  public void executeStartupTasks(ComponentContainer pico) {
    final ComponentContainer startupContainer = pico.createChild();
    startupContainer.addSingleton(IndexSynchronizer.class);
    startupContainer.addSingleton(RegisterMetrics.class);
    startupContainer.addSingleton(RegisterQualityGates.class);
    startupContainer.addSingleton(RegisterRules.class);
    startupContainer.addSingleton(RegisterQualityProfiles.class);
    startupContainer.addSingleton(JdbcDriverDeployer.class);
    startupContainer.addSingleton(RegisterDebtModel.class);
    startupContainer.addSingleton(GeneratePluginIndex.class);
    startupContainer.addSingleton(RegisterNewMeasureFilters.class);
    startupContainer.addSingleton(RegisterDashboards.class);
    startupContainer.addSingleton(RegisterPermissionTemplates.class);
    startupContainer.addSingleton(RenameDeprecatedPropertyKeys.class);
    startupContainer.addSingleton(LogServerId.class);
    startupContainer.addSingleton(RegisterServletFilters.class);
    startupContainer.addSingleton(CleanPreviewAnalysisCache.class);
    startupContainer.addSingleton(CopyRequirementsFromCharacteristicsToRules.class);
    startupContainer.addSingleton(AnalysisReportTaskCleaner.class);

    DoPrivileged.execute(new DoPrivileged.Task() {
      @Override
      protected void doPrivileged() {
        startupContainer.getComponentsByType(IndexSynchronizer.class).get(0).execute();
        startupContainer.startComponents();
        startupContainer.getComponentByType(ServerLifecycleNotifier.class).notifyStart();
      }
    });

    // Do not put the following statements in a finally block.
    // It would hide the possible exception raised during startup
    // See SONAR-3107
    startupContainer.stopComponents();

    pico.getComponentByType(DatabaseSessionFactory.class).clear();
  }
View Full Code Here

  /**
   * Start level 1 only
   */
  private void startLevel1Container() {
    level1Container = new ComponentContainer();
    level1Container.addSingletons(serverComponents.level1Components());
    level1Container.startComponents();
    currentContainer = level1Container;
  }
View Full Code Here

  private ComputationStepRegistry sut;

  @Before
  public void before() {
    ComponentContainer pico = new ComponentContainer();

    pico.addSingleton(mock(SynchronizeProjectPermissionsStep.class));
    pico.addSingleton(mock(IndexProjectIssuesStep.class));
    pico.addSingleton(mock(SwitchSnapshotStep.class));
    pico.addSingleton(mock(DataCleanerStep.class));
    pico.addSingleton(mock(InvalidatePreviewCacheStep.class));
    pico.addSingleton(mock(ComponentIndexationInDatabaseStep.class));

    sut = new ComputationStepRegistry(pico);
  }
View Full Code Here

  @Test
  public void should_filter_extensions_to_install() {
    BatchPluginRepository pluginRepository = mock(BatchPluginRepository.class);
    when(pluginRepository.getPluginsByMetadata()).thenReturn(newPlugin(Foo.class, Bar.class));
    ComponentContainer container = new ComponentContainer();
    ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);
    installer.install(container, new FooMatcher());

    assertThat(container.getComponentByType(Foo.class)).isNotNull();
    assertThat(container.getComponentByType(Bar.class)).isNull();
  }
View Full Code Here

  @Test
  public void should_execute_extension_provider() {
    BatchPluginRepository pluginRepository = mock(BatchPluginRepository.class);
    when(pluginRepository.getPluginsByMetadata()).thenReturn(newPlugin(new FooProvider(), new BarProvider()));
    ComponentContainer container = new ComponentContainer();
    ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);

    installer.install(container, new FooMatcher());

    assertThat(container.getComponentByType(Foo.class)).isNotNull();
    assertThat(container.getComponentByType(Bar.class)).isNull();
  }
View Full Code Here

  @Test
  public void should_provide_list_of_extensions() {
    BatchPluginRepository pluginRepository = mock(BatchPluginRepository.class);
    when(pluginRepository.getPluginsByMetadata()).thenReturn(newPlugin(new FooBarProvider()));
    ComponentContainer container = new ComponentContainer();
    ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);

    installer.install(container, new TrueMatcher());

    assertThat(container.getComponentByType(Foo.class)).isNotNull();
    assertThat(container.getComponentByType(Bar.class)).isNotNull();
  }
View Full Code Here

  @Test
  public void should_not_install_on_unsupported_environment() {
    BatchPluginRepository pluginRepository = mock(BatchPluginRepository.class);
    when(pluginRepository.getPluginsByMetadata()).thenReturn(newPlugin(Foo.class, MavenExtension.class, AntExtension.class, new BarProvider()));

    ComponentContainer container = new ComponentContainer();
    ExtensionInstaller installer = new ExtensionInstaller(pluginRepository, new EnvironmentInformation("ant", "1.7"), mode);

    installer.install(container, new TrueMatcher());

    assertThat(container.getComponentByType(MavenExtension.class)).isNull();
    assertThat(container.getComponentByType(AntExtension.class)).isNotNull();
    assertThat(container.getComponentByType(Foo.class)).isNotNull();
    assertThat(container.getComponentByType(Bar.class)).isNotNull();
  }
View Full Code Here

import static org.mockito.Mockito.mock;

public class BatchExtensionDictionnaryTest {

  private BatchExtensionDictionnary newSelector(BatchExtension... extensions) {
    ComponentContainer iocContainer = new ComponentContainer();
    for (BatchExtension extension : extensions) {
      iocContainer.addSingleton(extension);
    }
    return new BatchExtensionDictionnary(iocContainer, mock(SensorContext.class), mock(AnalyzerOptimizer.class));
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.platform.ComponentContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.