Search in sources :

Example 11 with OptionsMap

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

the class CompositeDriverConfigTest method setup.

@Before
public void setup() {
    primaryMap = new OptionsMap();
    // We need at least one option so that the default profile exists. Do it now to avoid having to
    // do it in every test. We use an option that we won't reuse in the tests so that there are no
    // unwanted interactions.
    primaryMap.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_PAGES, 1);
    fallbackMap = new OptionsMap();
    fallbackMap.put(TypedDriverOption.CONTINUOUS_PAGING_MAX_PAGES, 1);
    DriverConfigLoader compositeLoader = DriverConfigLoader.compose(DriverConfigLoader.fromMap(primaryMap), DriverConfigLoader.fromMap(fallbackMap));
    compositeConfig = compositeLoader.getInitialConfig();
    compositeDefaultProfile = compositeConfig.getDefaultProfile();
}
Also used : OptionsMap(com.datastax.oss.driver.api.core.config.OptionsMap) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) Before(org.junit.Before)

Example 12 with OptionsMap

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

the class MapBasedDriverConfigTest method should_create_derived_profile_overriding_option.

@Test
public void should_create_derived_profile_overriding_option() {
    OptionsMap source = new OptionsMap();
    source.put(MockTypedOptions.INT1, 42);
    DriverConfig config = DriverConfigLoader.fromMap(source).getInitialConfig();
    DriverExecutionProfile base = config.getDefaultProfile();
    DriverExecutionProfile derived = base.withInt(MockOptions.INT1, 43);
    assertThat(base.getInt(MockOptions.INT1)).isEqualTo(42);
    assertThat(derived.getInt(MockOptions.INT1)).isEqualTo(43);
}
Also used : OptionsMap(com.datastax.oss.driver.api.core.config.OptionsMap) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig) Test(org.junit.Test)

Example 13 with OptionsMap

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

the class MapBasedDriverConfigTest method should_create_derived_profile_unsetting_option.

@Test
public void should_create_derived_profile_unsetting_option() {
    OptionsMap source = new OptionsMap();
    source.put(MockTypedOptions.INT1, 42);
    source.put(MockTypedOptions.INT2, 43);
    DriverConfig config = DriverConfigLoader.fromMap(source).getInitialConfig();
    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 : OptionsMap(com.datastax.oss.driver.api.core.config.OptionsMap) DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig) Test(org.junit.Test)

Aggregations

OptionsMap (com.datastax.oss.driver.api.core.config.OptionsMap)13 Test (org.junit.Test)10 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)7 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)4 CqlSession (com.datastax.oss.driver.api.core.CqlSession)2 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)2 DefaultDriverConfigLoader (com.datastax.oss.driver.internal.core.config.typesafe.DefaultDriverConfigLoader)2 AllNodesFailedException (com.datastax.oss.driver.api.core.AllNodesFailedException)1 ResultSet (com.datastax.oss.driver.api.core.cql.ResultSet)1 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1 Node (com.datastax.oss.driver.api.core.metadata.Node)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1