use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class GrpcConfigTest method constructor_PropertiesWithPortGiven_ShouldLoadProperly.
@Test
public void constructor_PropertiesWithPortGiven_ShouldLoadProperly() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_HOST);
props.setProperty(DatabaseConfig.CONTACT_PORT, Integer.toString(ANY_PORT));
props.setProperty(DatabaseConfig.STORAGE, "grpc");
// Act
GrpcConfig config = new GrpcConfig(new DatabaseConfig(props));
// Assert
assertThat(config.getHost()).isEqualTo(ANY_HOST);
assertThat(config.getPort()).isEqualTo(ANY_PORT);
assertThat(config.getDeadlineDurationMillis()).isEqualTo(GrpcConfig.DEFAULT_DEADLINE_DURATION_MILLIS);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class GrpcConfigTest method constructor_PropertiesWithoutPortGiven_ShouldLoadProperly.
@Test
public void constructor_PropertiesWithoutPortGiven_ShouldLoadProperly() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_HOST);
props.setProperty(DatabaseConfig.STORAGE, "grpc");
// Act
GrpcConfig config = new GrpcConfig(new DatabaseConfig(props));
// Assert
assertThat(config.getHost()).isEqualTo(ANY_HOST);
assertThat(config.getPort()).isEqualTo(GrpcConfig.DEFAULT_SCALAR_DB_SERVER_PORT);
assertThat(config.getDeadlineDurationMillis()).isEqualTo(GrpcConfig.DEFAULT_DEADLINE_DURATION_MILLIS);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class DynamoConfigTest method constructor_WithoutStorage_ShouldThrowIllegalArgumentException.
@Test
public void constructor_WithoutStorage_ShouldThrowIllegalArgumentException() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_REGION);
props.setProperty(DatabaseConfig.USERNAME, ANY_ACCESS_KEY_ID);
props.setProperty(DatabaseConfig.PASSWORD, ANY_SECRET_ACCESS_ID);
props.setProperty(DynamoConfig.ENDPOINT_OVERRIDE, ANY_ENDPOINT_OVERRIDE);
props.setProperty(DynamoConfig.TABLE_METADATA_NAMESPACE, ANY_TABLE_METADATA_NAMESPACE);
// Act Assert
assertThatThrownBy(() -> new DynamoConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class DynamoConfigTest method constructor_PropertiesWithoutEndpointOverrideGiven_ShouldLoadProperly.
@Test
public void constructor_PropertiesWithoutEndpointOverrideGiven_ShouldLoadProperly() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_REGION);
props.setProperty(DatabaseConfig.USERNAME, ANY_ACCESS_KEY_ID);
props.setProperty(DatabaseConfig.PASSWORD, ANY_SECRET_ACCESS_ID);
props.setProperty(DatabaseConfig.STORAGE, DYNAMO_STORAGE);
props.setProperty(DynamoConfig.TABLE_METADATA_NAMESPACE, ANY_TABLE_METADATA_NAMESPACE);
// Act
DynamoConfig config = new DynamoConfig(new DatabaseConfig(props));
// Assert
assertThat(config.getRegion()).isEqualTo(ANY_REGION);
assertThat(config.getAccessKeyId()).isEqualTo(ANY_ACCESS_KEY_ID);
assertThat(config.getSecretAccessKey()).isEqualTo(ANY_SECRET_ACCESS_ID);
assertThat(config.getEndpointOverride().isPresent()).isFalse();
assertThat(config.getTableMetadataNamespace()).isPresent();
assertThat(config.getTableMetadataNamespace().get()).isEqualTo(ANY_TABLE_METADATA_NAMESPACE);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class ConsensusCommitConfigTest method constructor_PropertiesWithIsolationLevelGiven_ShouldLoadProperly.
@Test
public void constructor_PropertiesWithIsolationLevelGiven_ShouldLoadProperly() {
// Arrange
Properties props = new Properties();
props.setProperty(ConsensusCommitConfig.ISOLATION_LEVEL, Isolation.SERIALIZABLE.toString());
// Act
ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
// Assert
assertThat(config.getIsolation()).isEqualTo(Isolation.SERIALIZABLE);
}
Aggregations