use of com.datastax.oss.driver.api.core.NoNodeAvailableException in project java-driver by datastax.
the class NodeTargetingIT method should_fail_if_node_is_not_connected.
@Test
public void should_fail_if_node_is_not_connected() {
// given a statement with node explicitly set that for which we have no active pool.
Node node4 = getNode(4);
Statement statement = SimpleStatement.newInstance("select * system.local").setNode(node4);
try {
// when statement is executed
SESSION_RULE.session().execute(statement);
fail("Query should have failed");
} catch (NoNodeAvailableException e) {
assertThat(e.getAllErrors()).isEmpty();
} catch (AllNodesFailedException e) {
// its also possible that the query is tried. This can happen if the node was marked
// down, but not all connections have been closed yet. In this case, just verify that
// the expected host failed.
assertThat(e.getAllErrors().size()).isEqualTo(1);
assertThat(e.getAllErrors()).containsOnlyKeys(node4);
}
}
Aggregations