Search in sources :

Example 36 with DriverConfig

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

the class DefaultProgrammaticDriverConfigLoaderBuilderTest method should_honor_root_path.

@Test
public void should_honor_root_path() {
    String rootPath = "test-root";
    String propertyKey = rootPath + "." + DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE.getPath();
    try {
        System.setProperty(propertyKey, "42");
        DriverConfigLoader loader = new DefaultProgrammaticDriverConfigLoaderBuilder(DefaultProgrammaticDriverConfigLoaderBuilder.DEFAULT_FALLBACK_SUPPLIER, rootPath).withInt(DefaultDriverOption.REQUEST_PAGE_SIZE, 1234).build();
        DriverConfig config = loader.getInitialConfig();
        assertThat(config.getDefaultProfile().getInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE)).isEqualTo(42);
        assertThat(config.getDefaultProfile().getInt(DefaultDriverOption.REQUEST_PAGE_SIZE)).isEqualTo(1234);
    } finally {
        System.clearProperty(propertyKey);
    }
}
Also used : DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) Test(org.junit.Test)

Example 37 with DriverConfig

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

the class DefaultProgrammaticDriverConfigLoaderBuilderTest method should_override_option_in_default_profile.

@Test
public void should_override_option_in_default_profile() {
    DriverConfigLoader loader = new DefaultProgrammaticDriverConfigLoaderBuilder(() -> ConfigFactory.parseString(FALLBACK_CONFIG), "").withInt(MockOptions.INT1, 3).build();
    DriverConfig config = loader.getInitialConfig();
    assertThat(config.getDefaultProfile().getInt(MockOptions.INT1)).isEqualTo(3);
    assertThat(config.getDefaultProfile().getInt(MockOptions.INT2)).isEqualTo(2);
}
Also used : DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) Test(org.junit.Test)

Example 38 with DriverConfig

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

the class DefaultProgrammaticDriverConfigLoaderBuilderTest method should_override_option_in_existing_profile.

@Test
public void should_override_option_in_existing_profile() {
    DriverConfigLoader loader = new DefaultProgrammaticDriverConfigLoaderBuilder(() -> ConfigFactory.parseString(FALLBACK_CONFIG), "").startProfile("profile1").withInt(MockOptions.INT1, 3).build();
    DriverConfig config = loader.getInitialConfig();
    assertThat(config.getDefaultProfile().getInt(MockOptions.INT1)).isEqualTo(1);
    assertThat(config.getProfile("profile1").getInt(MockOptions.INT1)).isEqualTo(3);
}
Also used : DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) Test(org.junit.Test)

Example 39 with DriverConfig

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

the class DefaultProgrammaticDriverConfigLoaderBuilderTest method should_handle_multiple_programmatic_profiles.

@Test
public void should_handle_multiple_programmatic_profiles() {
    DriverConfigLoader loader = new DefaultProgrammaticDriverConfigLoaderBuilder(() -> ConfigFactory.parseString(FALLBACK_CONFIG), "").startProfile("profile2").withInt(MockOptions.INT1, 3).startProfile("profile3").withInt(MockOptions.INT1, 4).build();
    DriverConfig config = loader.getInitialConfig();
    assertThat(config.getProfile("profile2").getInt(MockOptions.INT1)).isEqualTo(3);
    assertThat(config.getProfile("profile3").getInt(MockOptions.INT1)).isEqualTo(4);
}
Also used : DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig) DriverConfigLoader(com.datastax.oss.driver.api.core.config.DriverConfigLoader) Test(org.junit.Test)

Example 40 with DriverConfig

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

the class GraphSupportCheckerTest method contextGraphPagingEnabled.

private void contextGraphPagingEnabled(InternalDriverContext context, PagingEnabledOptions option) {
    DriverExecutionProfile driverExecutionProfile = mock(DriverExecutionProfile.class);
    when(driverExecutionProfile.getString(DseDriverOption.GRAPH_PAGING_ENABLED)).thenReturn(option.name());
    DriverConfig config = mock(DriverConfig.class);
    when(context.getConfig()).thenReturn(config);
    when(config.getDefaultProfile()).thenReturn(driverExecutionProfile);
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) DriverConfig(com.datastax.oss.driver.api.core.config.DriverConfig)

Aggregations

DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)46 Test (org.junit.Test)31 DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)22 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)16 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)10 Node (com.datastax.oss.driver.api.core.metadata.Node)9 LoggerTest (com.datastax.oss.driver.internal.core.util.LoggerTest)8 OptionsMap (com.datastax.oss.driver.api.core.config.OptionsMap)7 DefaultNodeMetric (com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)7 NodeMetric (com.datastax.oss.driver.api.core.metrics.NodeMetric)7 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)6 DriverContext (com.datastax.oss.driver.api.core.context.DriverContext)4 MetricIdGenerator (com.datastax.oss.driver.internal.core.metrics.MetricIdGenerator)4 DseNodeMetric (com.datastax.dse.driver.api.core.metrics.DseNodeMetric)3 DefaultDriverOption (com.datastax.oss.driver.api.core.config.DefaultDriverOption)3 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)3 Duration (java.time.Duration)3 MetricRegistry (com.codahale.metrics.MetricRegistry)2 ProtocolVersion (com.datastax.oss.driver.api.core.ProtocolVersion)2 DriverOption (com.datastax.oss.driver.api.core.config.DriverOption)2