Search in sources :

Example 91 with DriverExecutionProfile

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));
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile) Node(com.datastax.oss.driver.api.core.metadata.Node) Test(org.junit.Test) UseDataProvider(com.tngtech.java.junit.dataprovider.UseDataProvider)

Example 92 with DriverExecutionProfile

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;
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Example 93 with DriverExecutionProfile

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;
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Example 94 with DriverExecutionProfile

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;
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Example 95 with DriverExecutionProfile

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;
}
Also used : DriverExecutionProfile(com.datastax.oss.driver.api.core.config.DriverExecutionProfile)

Aggregations

DriverExecutionProfile (com.datastax.oss.driver.api.core.config.DriverExecutionProfile)140 Test (org.junit.Test)81 UseDataProvider (com.tngtech.java.junit.dataprovider.UseDataProvider)29 DriverConfig (com.datastax.oss.driver.api.core.config.DriverConfig)20 CqlSession (com.datastax.oss.driver.api.core.CqlSession)19 InternalDriverContext (com.datastax.oss.driver.internal.core.context.InternalDriverContext)17 Node (com.datastax.oss.driver.api.core.metadata.Node)14 ByteBuffer (java.nio.ByteBuffer)13 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)12 Duration (java.time.Duration)11 GraphTestUtils.createGraphBinaryModule (com.datastax.dse.driver.internal.core.graph.GraphTestUtils.createGraphBinaryModule)10 GraphBinaryModule (com.datastax.dse.driver.internal.core.graph.binary.GraphBinaryModule)10 Row (com.datastax.oss.driver.api.core.cql.Row)9 Test (org.junit.jupiter.api.Test)9 LoggerTest (com.datastax.oss.driver.internal.core.util.LoggerTest)8 DefaultNodeMetric (com.datastax.oss.driver.api.core.metrics.DefaultNodeMetric)7 NodeMetric (com.datastax.oss.driver.api.core.metrics.NodeMetric)7 Message (com.datastax.oss.protocol.internal.Message)7 DriverTimeoutException (com.datastax.oss.driver.api.core.DriverTimeoutException)6 DriverConfigLoader (com.datastax.oss.driver.api.core.config.DriverConfigLoader)6