Search in sources :

Example 16 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class TypesafeDriverConfigTest method should_create_derived_profile_unsetting_option.

@Test
public void should_create_derived_profile_unsetting_option() {
    TypesafeDriverConfig config = parse("int1 = 42\n int2 = 43");
    DriverExecutionProfile base = config.getDefaultProfile();
    DriverExecutionProfile derived = base.without(MockOptions.INT2);
    assertThat(base.getInt(MockOptions.INT2)).isEqualTo(43);
    assertThat(derived.isDefined(MockOptions.INT2)).isFalse();
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.Test)

Example 17 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class TypesafeDriverConfigTest method should_create_derived_profile_with_new_option.

@Test
public void should_create_derived_profile_with_new_option() {
    TypesafeDriverConfig config = parse("int1 = 42");
    DriverExecutionProfile base = config.getDefaultProfile();
    DriverExecutionProfile derived = base.withInt(MockOptions.INT2, 43);
    assertThat(base.isDefined(MockOptions.INT2)).isFalse();
    assertThat(derived.isDefined(MockOptions.INT2)).isTrue();
    assertThat(derived.getInt(MockOptions.INT2)).isEqualTo(43);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.Test)

Example 18 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class TypesafeDriverConfigTest method should_update_derived_profiles_after_reloading.

@Test
public void should_update_derived_profiles_after_reloading() {
    TypesafeDriverConfig config = parse("int1 = 42\n profiles { profile1 { int1 = 43 } }");
    DriverExecutionProfile derivedFromDefault = config.getDefaultProfile().withInt(MockOptions.INT2, 50);
    DriverExecutionProfile derivedFromProfile1 = config.getProfile("profile1").withInt(MockOptions.INT2, 51);
    config.reload(ConfigFactory.parseString("int1 = 44\n profiles { profile1 { int1 = 45 } }"));
    assertThat(derivedFromDefault.getInt(MockOptions.INT1)).isEqualTo(44);
    assertThat(derivedFromDefault.getInt(MockOptions.INT2)).isEqualTo(50);
    assertThat(derivedFromProfile1.getInt(MockOptions.INT1)).isEqualTo(45);
    assertThat(derivedFromProfile1.getInt(MockOptions.INT2)).isEqualTo(51);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Test(org.junit.Test)

Example 19 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class DefaultDriverContextTest method buildMockedContext.

private DefaultDriverContext buildMockedContext(Optional<String> compressionOption) {
    DriverExecutionProfile defaultProfile = mock(DriverExecutionProfile.class);
    when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn(compressionOption.orElse("none"));
    return MockedDriverContextFactory.defaultDriverContext(Optional.of(defaultProfile));
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Example 20 with DriverExecutionProfile

use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.

the class StartupOptionsBuilderTest method buildMockedContext.

private DefaultDriverContext buildMockedContext(String compression) {
    DriverExecutionProfile defaultProfile = mock(DriverExecutionProfile.class);
    when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn(compression);
    return MockedDriverContextFactory.defaultDriverContext(Optional.of(defaultProfile));
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Aggregations

DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)140 Test (org.junit.Test)81 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)29 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)20 CqlSession (com.datastax.oss.driver.api.core.CqlSession)19 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)17 Node (com.datastax.oss.driver.api.core.metadata.Node)14 ByteBuffer (java.nio.ByteBuffer)13 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)12 Duration (java.time.Duration)11 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)10 GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)10 Row (com.datastax.oss.driver.api.core.cql.Row)9 Test (org.junit.jupiter.api.Test)9 LoggerTest (com.datastax.oss.driver.internal.core.util.LoggerTest)8 DefaultNodeMetric (com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)7 NodeMetric (com.datastax.oss.driver.api.core.metrics.NodeMetric)7 Message (com.datastax.oss.protocol.internal.Message)7 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)6 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)6