Search in sources :

Example 6 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.

the class StartupMetadataProviderTest method fail_to_load_from_database_if_properties_are_not_persisted.

@Test
public void fail_to_load_from_database_if_properties_are_not_persisted() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE);
    cluster.setStartupLeader(false);
    expectedException.expect(IllegalStateException.class);
    expectedException.expectMessage("Property sonar.core.startTime is missing in database");
    underTest.provide(system, runtime, cluster, dbTester.getDbClient());
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Test(org.junit.Test)

Example 7 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.

the class StartupMetadataProviderTest method load_from_database_if_compute_engine_of_startup_follower_server.

@Test
public void load_from_database_if_compute_engine_of_startup_follower_server() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarQube(Version.create(6, 1), SonarQubeSide.COMPUTE_ENGINE);
    testLoadingFromDatabase(runtime, false);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Test(org.junit.Test)

Example 8 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.

the class XooPluginTest method provide_extensions_for_5_4.

@Test
public void provide_extensions_for_5_4() {
    SonarRuntime runtime = SonarRuntimeImpl.forSonarLint(Version.parse("5.4"));
    Plugin.Context context = new Plugin.Context(runtime);
    new XooPlugin().define(context);
    assertThat(context.getExtensions()).hasSize(44).doesNotContain(CpdTokenizerSensor.class);
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) Plugin(org.sonar.api.Plugin) Test(org.junit.Test)

Example 9 with SonarRuntime

use of org.sonar.api.SonarRuntime in project sonarqube by SonarSource.

the class SonarRuntimeImplTest method sonarLint_environment.

@Test
public void sonarLint_environment() {
    SonarRuntime apiVersion = SonarRuntimeImpl.forSonarLint(A_VERSION);
    assertThat(apiVersion.getApiVersion()).isEqualTo(A_VERSION);
    assertThat(apiVersion.getProduct()).isEqualTo(SonarProduct.SONARLINT);
    try {
        apiVersion.getSonarQubeSide();
        Assertions.fail("Expected exception");
    } catch (Exception e) {
        assertThat(e).isInstanceOf(UnsupportedOperationException.class);
    }
}
Also used : SonarRuntime(org.sonar.api.SonarRuntime) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)9 SonarRuntime (org.sonar.api.SonarRuntime)9 Plugin (org.sonar.api.Plugin)2 ExpectedException (org.junit.rules.ExpectedException)1