Search in sources :

Example 1 with ClusterNameMismatchException

use of com.datastax.oss.driver.internal.core.channel.ClusterNameMismatchException in project java-driver by datastax.

the class ChannelPoolInitTest method should_fire_force_down_event_when_cluster_name_does_not_match.

@Test
public void should_fire_force_down_event_when_cluster_name_does_not_match() throws Exception {
    when(defaultProfile.getInt(DefaultDriverOption.CONNECTION_POOL_LOCAL_SIZE)).thenReturn(3);
    ClusterNameMismatchException error = new ClusterNameMismatchException(node.getEndPoint(), "actual", "expected");
    MockChannelFactoryHelper factoryHelper = MockChannelFactoryHelper.builder(channelFactory).failure(node, error).failure(node, error).failure(node, error).build();
    ChannelPool.init(node, null, NodeDistance.LOCAL, context, "test");
    factoryHelper.waitForCalls(node, 3);
    verify(eventBus, VERIFY_TIMEOUT).fire(TopologyEvent.forceDown(node.getBroadcastRpcAddress().get()));
    verify(eventBus, never()).fire(ChannelEvent.channelOpened(node));
    verify(nodeMetricUpdater, VERIFY_TIMEOUT.times(3)).incrementCounter(DefaultNodeMetric.CONNECTION_INIT_ERRORS, null);
    factoryHelper.verifyNoMoreCalls();
}
Also used : MockChannelFactoryHelper(com.datastax.oss.driver.internal.core.channel.MockChannelFactoryHelper) ClusterNameMismatchException(com.datastax.oss.driver.internal.core.channel.ClusterNameMismatchException) Test(org.junit.Test)

Aggregations

ClusterNameMismatchException (com.datastax.oss.driver.internal.core.channel.ClusterNameMismatchException)1 MockChannelFactoryHelper (com.datastax.oss.driver.internal.core.channel.MockChannelFactoryHelper)1 Test (org.junit.Test)1