Skip to content

Commit

Permalink
improve verification of test for missing Datacenter
Browse files Browse the repository at this point in the history
  • Loading branch information
emerkle826 committed Feb 8, 2021
1 parent 503133c commit fe6b846
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
import org.testcontainers.containers.wait.CassandraQueryWaitStrategy;
import org.testcontainers.utility.DockerImageName;

import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

/**
* @author Eugeny Karpov
Expand Down Expand Up @@ -116,13 +119,17 @@ public void testCassandraGetCluster() {
}
}

@Test(expected = IllegalStateException.class)
@Test
public void testMissingLocalDatacenter() {
try (CassandraContainer<?> cassandraContainer = new CassandraContainer<>(CASSANDRA_IMAGE)) {
cassandraContainer.start();
// Trying to build a CqlSession will fail if a Contact Point is specified,
// but Local Datacenter is omitted.
CqlSession.builder().addContactPoint(cassandraContainer.getContactPoint()).build();
fail("Session build should fail if no local Datacenter provided");
} catch (IllegalStateException ise) {
String msg = "Since you provided explicit contact points, the local DC must be explicitly set";
assertThat(ise.getMessage(), containsString(msg));
}
}

Expand Down

0 comments on commit fe6b846

Please sign in to comment.