public class CloseableLoadBalancingPolicyTest {
@Test(groups = "short")
public void should_be_invoked_at_shutdown() {
CloseMonitoringPolicy policy = new CloseMonitoringPolicy(Policies.defaultLoadBalancingPolicy());
CCMBridge ccm = null;
Cluster cluster = null;
try {
ccm = CCMBridge.create("test", 1);
cluster = Cluster.builder()
.addContactPoint(CCMBridge.ipOfNode(1))
.withLoadBalancingPolicy(policy)
.build();
cluster.connect();
} finally {
if (cluster != null)
cluster.close();
if (ccm != null)
ccm.remove();
}
assertThat(policy.wasClosed).isTrue();
}