use of com.datastax.oss.driver.api.core.config.DriverConfig 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();
}
use of com.datastax.oss.driver.api.core.config.DriverConfig 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);
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class DefaultDriverConfigLoaderTest method should_detect_config_change_from_periodic_reload.
@Test
public void should_detect_config_change_from_periodic_reload() {
DefaultDriverConfigLoader loader = new DefaultDriverConfigLoader(() -> ConfigFactory.parseString(configSource.get()));
DriverConfig initialConfig = loader.getInitialConfig();
assertThat(initialConfig).hasIntOption(MockOptions.INT1, 42);
loader.onDriverInit(context);
adminExecutor.waitForNonScheduledTasks();
CapturedTask<?> task = adminExecutor.nextTask();
configSource.set("int1 = 43");
task.run();
assertThat(initialConfig).hasIntOption(MockOptions.INT1, 43);
verify(eventBus).fire(ConfigChangeEvent.INSTANCE);
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class DefaultProgrammaticDriverConfigLoaderBuilderTest method should_go_back_to_default_profile_when_profile_ends.
@Test
public void should_go_back_to_default_profile_when_profile_ends() {
DriverConfigLoader loader = new DefaultProgrammaticDriverConfigLoaderBuilder(() -> ConfigFactory.parseString(FALLBACK_CONFIG), "").startProfile("profile2").withInt(MockOptions.INT1, 3).endProfile().withInt(MockOptions.INT1, 4).build();
DriverConfig config = loader.getInitialConfig();
assertThat(config.getDefaultProfile().getInt(MockOptions.INT1)).isEqualTo(4);
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class DefaultProgrammaticDriverConfigLoaderBuilderTest method should_override_option_in_new_profile.
@Test
public void should_override_option_in_new_profile() {
DriverConfigLoader loader = new DefaultProgrammaticDriverConfigLoaderBuilder(() -> ConfigFactory.parseString(FALLBACK_CONFIG), "").startProfile("profile2").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(11);
assertThat(config.getProfile("profile2").getInt(MockOptions.INT1)).isEqualTo(3);
assertThat(config.getProfile("profile2").getInt(MockOptions.INT2)).isEqualTo(2);
}
Aggregations