use of com.datastax.oss.driver.api.core.config.DriverConfig in project spring-boot by spring-projects.
the class CassandraAutoConfigurationTests method driverConfigLoaderWithConfigCreateProfiles.
@Test
void driverConfigLoaderWithConfigCreateProfiles() {
String configLocation = "org/springframework/boot/autoconfigure/cassandra/profiles.conf";
this.contextRunner.withPropertyValues("spring.data.cassandra.config=" + configLocation).run((context) -> {
assertThat(context).hasSingleBean(DriverConfigLoader.class);
DriverConfig driverConfig = context.getBean(DriverConfigLoader.class).getInitialConfig();
assertThat(driverConfig.getProfiles()).containsOnlyKeys("default", "first", "second");
assertThat(driverConfig.getProfile("first").getDuration(DefaultDriverOption.REQUEST_TIMEOUT)).isEqualTo(Duration.ofMillis(100));
});
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class DefaultDriverConfigLoaderTest method should_not_notify_from_periodic_reload_if_config_has_not_changed.
@Test
public void should_not_notify_from_periodic_reload_if_config_has_not_changed() {
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();
// no change to the config source
task.run();
verify(eventBus, never()).fire(ConfigChangeEvent.INSTANCE);
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class MockedDriverContextFactory method defaultDriverContext.
public static DefaultDriverContext defaultDriverContext(Optional<DriverExecutionProfile> profileOption) {
/* If the caller provided a profile use that, otherwise make a new one */
final DriverExecutionProfile profile = profileOption.orElseGet(() -> {
DriverExecutionProfile blankProfile = mock(DriverExecutionProfile.class);
when(blankProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn("none");
when(blankProfile.getDuration(DefaultDriverOption.METRICS_NODE_EXPIRE_AFTER)).thenReturn(Duration.ofMinutes(5));
when(blankProfile.isDefined(DefaultDriverOption.METRICS_FACTORY_CLASS)).thenReturn(true);
when(blankProfile.getString(DefaultDriverOption.METRICS_FACTORY_CLASS)).thenReturn("DefaultMetricsFactory");
return blankProfile;
});
/* Setup machinery to connect the input DriverExecutionProfile to the config loader */
final DriverConfig driverConfig = mock(DriverConfig.class);
final DriverConfigLoader configLoader = mock(DriverConfigLoader.class);
when(configLoader.getInitialConfig()).thenReturn(driverConfig);
when(driverConfig.getDefaultProfile()).thenReturn(profile);
ProgrammaticArguments args = ProgrammaticArguments.builder().withNodeStateListener(mock(NodeStateListener.class)).withSchemaChangeListener(mock(SchemaChangeListener.class)).withRequestTracker(mock(RequestTracker.class)).withLocalDatacenters(Maps.newHashMap()).withNodeDistanceEvaluators(Maps.newHashMap()).build();
return new DefaultDriverContext(configLoader, args);
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class MapBasedDriverConfigTest method should_override_option_in_profile.
@Test
public void should_override_option_in_profile() {
OptionsMap source = new OptionsMap();
source.put(MockTypedOptions.INT1, 42);
source.put("profile1", MockTypedOptions.INT1, 43);
DriverConfig config = DriverConfigLoader.fromMap(source).getInitialConfig();
assertThat(config).hasIntOption(MockOptions.INT1, 42).hasIntOption("profile1", MockOptions.INT1, 43);
}
use of com.datastax.oss.driver.api.core.config.DriverConfig in project java-driver by datastax.
the class MapBasedDriverConfigTest method should_load_minimal_config_with_no_profiles.
@Test
public void should_load_minimal_config_with_no_profiles() {
OptionsMap source = new OptionsMap();
source.put(MockTypedOptions.INT1, 42);
DriverConfig config = DriverConfigLoader.fromMap(source).getInitialConfig();
assertThat(config).hasIntOption(MockOptions.INT1, 42);
}
Aggregations