use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class DataCentersFinderTest method should_detect_data_centers.
@Test
@UseDataProvider("hostProvider")
public void should_detect_data_centers(int numberOfRemoteHosts, String dc1, NodeDistance h1Distance, String dc2, NodeDistance h2Distance, Set<String> expected) {
// given
DriverExecutionProfile executionProfile = mock(DriverExecutionProfile.class);
when(executionProfile.getInt(CONNECTION_POOL_REMOTE_SIZE)).thenReturn(numberOfRemoteHosts);
Collection<Node> nodes = mockNodes(dc1, h1Distance, dc2, h2Distance);
// when
Set<String> dataCenters = new DataCentersFinder().getDataCenters(nodes, executionProfile);
// then
assertThat(dataCenters).isEqualTo(Sets.newHashSet(expected));
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfileMockUtil method mockNonDefaultLoadBalancingExecutionProfile.
static DriverExecutionProfile mockNonDefaultLoadBalancingExecutionProfile() {
DriverExecutionProfile profile = mockDefaultExecutionProfile();
when(profile.getString(LOAD_BALANCING_POLICY_CLASS)).thenReturn("NonDefaultLoadBalancing");
return profile;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfileMockUtil method mockNonDefaultConsistency.
static DriverExecutionProfile mockNonDefaultConsistency() {
DriverExecutionProfile profile = mockDefaultExecutionProfile();
when(profile.getString(REQUEST_CONSISTENCY)).thenReturn("ALL");
return profile;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfileMockUtil method mockNonDefaultSpeculativeExecutionInfo.
static DriverExecutionProfile mockNonDefaultSpeculativeExecutionInfo() {
DriverExecutionProfile profile = mockDefaultExecutionProfile();
when(profile.getString(SPECULATIVE_EXECUTION_POLICY_CLASS)).thenReturn("NonDefaultSpecexPolicy");
return profile;
}
use of com.datastax.oss.driver.api.core.config.DriverExecutionProfile in project java-driver by datastax.
the class ExecutionProfileMockUtil method mockUndefinedLocalDcExecutionProfile.
static DriverExecutionProfile mockUndefinedLocalDcExecutionProfile() {
DriverExecutionProfile profile = mockNonDefaultLoadBalancingExecutionProfile();
when(profile.isDefined(LOAD_BALANCING_LOCAL_DATACENTER)).thenReturn(false);
return profile;
}
Aggregations