Search in sources :

Example 1 with ExponentialReconnectionPolicy

use of com.datastax.oss.driver.internal.core.connection.ExponentialReconnectionPolicy in project java-driver by datastax.

the class ReconnectionPolicyInfoFinderTest method should_find_an_info_about_exponential_reconnection_policy.

@Test
public void should_find_an_info_about_exponential_reconnection_policy() {
    ExponentialReconnectionPolicy exponentialReconnectionPolicy = mock(ExponentialReconnectionPolicy.class);
    when(exponentialReconnectionPolicy.getBaseDelayMs()).thenReturn(100L);
    when(exponentialReconnectionPolicy.getMaxAttempts()).thenReturn(10L);
    when(exponentialReconnectionPolicy.getMaxDelayMs()).thenReturn(200L);
    // when
    ReconnectionPolicyInfo reconnectionPolicyInfo = new ReconnectionPolicyInfoFinder().getReconnectionPolicyInfo(exponentialReconnectionPolicy, null);
    // then
    assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("baseDelayMs", 100L));
    assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("maxAttempts", 10L));
    assertThat(reconnectionPolicyInfo.getOptions()).contains(MapEntry.entry("maxDelayMs", 200L));
    assertThat(reconnectionPolicyInfo.getType()).contains("ExponentialReconnectionPolicy");
}
Also used : ReconnectionPolicyInfo(com.datastax.dse.driver.internal.core.insights.schema.ReconnectionPolicyInfo) ExponentialReconnectionPolicy(com.datastax.oss.driver.internal.core.connection.ExponentialReconnectionPolicy) Test(org.junit.Test)

Aggregations

ReconnectionPolicyInfo (com.datastax.dse.driver.internal.core.insights.schema.ReconnectionPolicyInfo)1 ExponentialReconnectionPolicy (com.datastax.oss.driver.internal.core.connection.ExponentialReconnectionPolicy)1 Test (org.junit.Test)1