use of com.datastax.oss.protocol.internal.request.Startup in project java-driver by datastax.
the class DseStartupOptionsBuilderTest method should_use_configuration_when_no_programmatic_values_provided.
@Test
public void should_use_configuration_when_no_programmatic_values_provided() {
when(defaultProfile.getString(DseDriverOption.APPLICATION_NAME, null)).thenReturn("Config_App_Name");
when(defaultProfile.getString(DseDriverOption.APPLICATION_VERSION, null)).thenReturn("Config_App_Version");
when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn("none");
buildContext(null, null, null);
Startup startup = new Startup(driverContext.getStartupOptions());
assertThat(startup.options).containsEntry(StartupOptionsBuilder.APPLICATION_NAME_KEY, "Config_App_Name").containsEntry(StartupOptionsBuilder.APPLICATION_VERSION_KEY, "Config_App_Version");
}
use of com.datastax.oss.protocol.internal.request.Startup in project java-driver by datastax.
the class DseStartupOptionsBuilderTest method should_build_startup_options_with_compression.
@Test
@DataProvider({ "lz4", "snappy" })
public void should_build_startup_options_with_compression(String compression) {
when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn(compression);
buildContext(null, null, null);
Startup startup = new Startup(driverContext.getStartupOptions());
// assert the compression option is present
assertThat(startup.options).containsEntry(Startup.COMPRESSION_KEY, compression);
assertThat(startup.options).doesNotContainKey(StartupOptionsBuilder.APPLICATION_NAME_KEY);
assertThat(startup.options).doesNotContainKey(StartupOptionsBuilder.APPLICATION_VERSION_KEY);
assertDefaultStartupOptions(startup);
}
use of com.datastax.oss.protocol.internal.request.Startup in project java-driver by datastax.
the class DseStartupOptionsBuilderTest method should_build_startup_options_with_application_version_and_name.
@Test
public void should_build_startup_options_with_application_version_and_name() {
when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn("none");
buildContext(null, "Custom_App_Name", "Custom_App_Version");
Startup startup = new Startup(driverContext.getStartupOptions());
// assert the app name and version are present
assertThat(startup.options).containsEntry(StartupOptionsBuilder.APPLICATION_NAME_KEY, "Custom_App_Name");
assertThat(startup.options).containsEntry(StartupOptionsBuilder.APPLICATION_VERSION_KEY, "Custom_App_Version");
assertThat(startup.options).doesNotContainKey(Startup.COMPRESSION_KEY);
assertDefaultStartupOptions(startup);
}
use of com.datastax.oss.protocol.internal.request.Startup in project java-driver by datastax.
the class DseStartupOptionsBuilderTest method should_fail_to_build_startup_options_with_invalid_compression.
@Test
public void should_fail_to_build_startup_options_with_invalid_compression() {
when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn("foobar");
buildContext(null, null, null);
assertThatIllegalArgumentException().isThrownBy(() -> new Startup(driverContext.getStartupOptions()));
}
use of com.datastax.oss.protocol.internal.request.Startup in project java-driver by datastax.
the class DseStartupOptionsBuilderTest method should_ignore_configuration_when_programmatic_values_provided.
@Test
public void should_ignore_configuration_when_programmatic_values_provided() {
when(defaultProfile.getString(DefaultDriverOption.PROTOCOL_COMPRESSION, "none")).thenReturn("none");
buildContext(null, "Custom_App_Name", "Custom_App_Version");
Startup startup = new Startup(driverContext.getStartupOptions());
assertThat(startup.options).containsEntry(StartupOptionsBuilder.APPLICATION_NAME_KEY, "Custom_App_Name").containsEntry(StartupOptionsBuilder.APPLICATION_VERSION_KEY, "Custom_App_Version");
}
Aggregations