Search in sources :

Example 16 with CassandraSourceConnectorConfig

use of com.datastax.oss.cdc.CassandraSourceConnectorConfig in project cdc-apache-cassandra by datastax.

the class CassandraSourceConnectorConfigTest method should_throw_when_secure_connect_bundle_and_local_dc_provided.

@Test
void should_throw_when_secure_connect_bundle_and_local_dc_provided() {
    Map<String, String> props = ImmutableMap.<String, String>builder().putAll(requiredSettings()).put(SECURE_CONNECT_BUNDLE_OPT, "/location/to/bundle").put(DC_OPT, "dc1").build();
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining(String.format("When %s parameter is specified you should not provide %s.", SECURE_CONNECT_BUNDLE_OPT, DC_OPT));
}
Also used : CassandraSourceConnectorConfig(com.datastax.oss.cdc.CassandraSourceConnectorConfig) ConfigException(com.datastax.oss.common.sink.ConfigException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with CassandraSourceConnectorConfig

use of com.datastax.oss.cdc.CassandraSourceConnectorConfig in project cdc-apache-cassandra by datastax.

the class CassandraSourceConnectorConfigTest method should_handle_maxConcurrentRequests.

@Test
void should_handle_maxConcurrentRequests() {
    Map<String, String> props = ImmutableMap.<String, String>builder().putAll(requiredSettings()).put(CONCURRENT_REQUESTS_OPT, "129").build();
    CassandraSourceConnectorConfig d = new CassandraSourceConnectorConfig(props);
    assertThat(d.getMaxConcurrentRequests()).isEqualTo(129);
}
Also used : CassandraSourceConnectorConfig(com.datastax.oss.cdc.CassandraSourceConnectorConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 18 with CassandraSourceConnectorConfig

use of com.datastax.oss.cdc.CassandraSourceConnectorConfig in project cdc-apache-cassandra by datastax.

the class CassandraSourceConnectorConfigTest method should_handle_contact_points_provided_using_connector_and_driver_prefix.

@ParameterizedTest
@MethodSource("contactPointsProvider")
void should_handle_contact_points_provided_using_connector_and_driver_prefix(String connectorContactPoints, String javaDriverPrefixContactPoints, List<String> expected, Map<String, String> expectedDriverSettings) {
    // given
    Map<String, String> connectorSettings = new HashMap<>(requiredSettings());
    if (connectorContactPoints != null) {
        connectorSettings.put(CONTACT_POINTS_OPT, connectorContactPoints);
    }
    if (javaDriverPrefixContactPoints != null) {
        connectorSettings.put(CONTACT_POINTS_DRIVER_SETTINGS, javaDriverPrefixContactPoints);
    }
    connectorSettings.put(LOCAL_DC_DRIVER_SETTING, "localDc");
    // when
    CassandraSourceConnectorConfig CassandraSourceConnectorConfig = new CassandraSourceConnectorConfig(connectorSettings);
    // then
    assertThat(CassandraSourceConnectorConfig.getContactPoints()).isEqualTo(expected);
    for (Map.Entry<String, String> entry : expectedDriverSettings.entrySet()) {
        assertThat(CassandraSourceConnectorConfig.getJavaDriverSettings()).contains(entry);
    }
}
Also used : CassandraSourceConnectorConfig(com.datastax.oss.cdc.CassandraSourceConnectorConfig) ImmutableMap(com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 19 with CassandraSourceConnectorConfig

use of com.datastax.oss.cdc.CassandraSourceConnectorConfig in project cdc-apache-cassandra by datastax.

the class CassandraSourceConnectorConfigTest method should_error_invalid_maxConcurrentRequests.

@Test
void should_error_invalid_maxConcurrentRequests() {
    Map<String, String> props = Maps.newHashMap(ImmutableMap.<String, String>builder().putAll(requiredSettings()).put(CONCURRENT_REQUESTS_OPT, "foo").build());
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining("Invalid value foo for configuration maxConcurrentRequests");
    props.put(CONCURRENT_REQUESTS_OPT, "0");
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining("Value must be at least 1");
    props.put(CONCURRENT_REQUESTS_OPT, "-1");
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining("Value must be at least 1");
}
Also used : CassandraSourceConnectorConfig(com.datastax.oss.cdc.CassandraSourceConnectorConfig) ConfigException(com.datastax.oss.common.sink.ConfigException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 20 with CassandraSourceConnectorConfig

use of com.datastax.oss.cdc.CassandraSourceConnectorConfig in project cdc-apache-cassandra by datastax.

the class CassandraSourceConnectorConfigTest method should_error_invalid_queryExecutionTimeout.

@Test
void should_error_invalid_queryExecutionTimeout() {
    Map<String, String> props = Maps.newHashMap(ImmutableMap.<String, String>builder().putAll(requiredSettings()).put(QUERY_EXECUTION_TIMEOUT_OPT, "foo").build());
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining("Invalid value foo for configuration queryExecutionTimeout");
    props.put(QUERY_EXECUTION_TIMEOUT_OPT, "0");
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining("Value must be at least 1");
    props.put(QUERY_EXECUTION_TIMEOUT_OPT, "-1");
    assertThatThrownBy(() -> new CassandraSourceConnectorConfig(props)).isInstanceOf(ConfigException.class).hasMessageContaining("Value must be at least 1");
}
Also used : CassandraSourceConnectorConfig(com.datastax.oss.cdc.CassandraSourceConnectorConfig) ConfigException(com.datastax.oss.common.sink.ConfigException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CassandraSourceConnectorConfig (com.datastax.oss.cdc.CassandraSourceConnectorConfig)29 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)27 Test (org.junit.jupiter.api.Test)22 ConfigException (com.datastax.oss.common.sink.ConfigException)13 MethodSource (org.junit.jupiter.params.provider.MethodSource)5 ImmutableMap (com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap)1 File (java.io.File)1 PosixFilePermission (java.nio.file.attribute.PosixFilePermission)1 KeyValue (org.apache.pulsar.common.schema.KeyValue)1