use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class MultiStorageConfigTest method constructor_NonExistentStorageForDefaultGiven_ShouldThrowIllegalArgumentException.
@Test
public void constructor_NonExistentStorageForDefaultGiven_ShouldThrowIllegalArgumentException() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.STORAGE, "multi-storage");
props.setProperty(MultiStorageConfig.STORAGES, "cassandra,mysql");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.storage", "cassandra");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.contact_points", "localhost");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.contact_port", "7000");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.username", "cassandra");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.password", "cassandra");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.storage", "jdbc");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.contact_points", "jdbc:mysql://localhost:3306/");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.username", "root");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.password", "mysql");
props.setProperty(MultiStorageConfig.TABLE_MAPPING, "user.order:cassandra,user.customer:mysql,coordinator.state:cassandra");
props.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, "namespace1:cassandra,namespace2:mysql");
// non-existent storage
props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "dynamo");
// Act Assert
assertThatThrownBy(() -> new MultiStorageConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class MultiStorageConfigTest method constructor_WrongStorageNameGiven_ShouldThrowIllegalArgumentException.
@Test
public void constructor_WrongStorageNameGiven_ShouldThrowIllegalArgumentException() {
Properties props = new Properties();
// wrong
props.setProperty(DatabaseConfig.STORAGE, "aaa");
props.setProperty(MultiStorageConfig.STORAGES, "cassandra,mysql");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.storage", "cassandra");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.contact_points", "localhost");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.contact_port", "7000");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.username", "cassandra");
props.setProperty(MultiStorageConfig.STORAGES + ".cassandra.password", "cassandra");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.storage", "jdbc");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.contact_points", "jdbc:mysql://localhost:3306/");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.username", "root");
props.setProperty(MultiStorageConfig.STORAGES + ".mysql.password", "mysql");
props.setProperty(MultiStorageConfig.TABLE_MAPPING, "user.order:cassandra,user.customer:mysql,coordinator.state:cassandra");
props.setProperty(MultiStorageConfig.NAMESPACE_MAPPING, "namespace1:cassandra,namespace2:mysql");
props.setProperty(MultiStorageConfig.DEFAULT_STORAGE, "cassandra");
// Act Assert
assertThatThrownBy(() -> new MultiStorageConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class GrpcConfigTest method constructor_PropertiesWithInvalidDeadlineDurationMillisGiven_ShouldThrowIllegalArgumentException.
@Test
public void constructor_PropertiesWithInvalidDeadlineDurationMillisGiven_ShouldThrowIllegalArgumentException() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_HOST);
props.setProperty(DatabaseConfig.STORAGE, "grpc");
props.setProperty(GrpcConfig.DEADLINE_DURATION_MILLIS, "aaa");
// Act
assertThatThrownBy(() -> new GrpcConfig(new DatabaseConfig(props))).isInstanceOf(IllegalArgumentException.class);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class GrpcConfigTest method constructor_PropertiesWithValidDeadlineDurationMillisGiven_ShouldLoadProperly.
@Test
public void constructor_PropertiesWithValidDeadlineDurationMillisGiven_ShouldLoadProperly() {
// Arrange
Properties props = new Properties();
props.setProperty(DatabaseConfig.CONTACT_POINTS, ANY_HOST);
props.setProperty(DatabaseConfig.STORAGE, "grpc");
props.setProperty(GrpcConfig.DEADLINE_DURATION_MILLIS, "5000");
// Act
GrpcConfig config = new GrpcConfig(new DatabaseConfig(props));
// Assert
assertThat(config.getHost()).isEqualTo(ANY_HOST);
assertThat(config.getDeadlineDurationMillis()).isEqualTo(5000);
}
use of com.scalar.db.config.DatabaseConfig in project scalardb by scalar-labs.
the class ConsensusCommitConfigTest method constructor_PropertiesWithCoordinatorNamespaceGiven_ShouldLoadProperly.
@Test
public void constructor_PropertiesWithCoordinatorNamespaceGiven_ShouldLoadProperly() {
// Arrange
Properties props = new Properties();
props.setProperty(ConsensusCommitConfig.COORDINATOR_NAMESPACE, "changed_coordinator");
// Act
ConsensusCommitConfig config = new ConsensusCommitConfig(new DatabaseConfig(props));
// Assert
assertThat(config.getCoordinatorNamespace()).isPresent();
assertThat(config.getCoordinatorNamespace().get()).isEqualTo("changed_coordinator");
}
Aggregations