How to add a simple context load test for Embedded Cassandra using Spring Boot ?

This sample below shows you the code to test your embedded Cassandra to test the context load which involves testing:

  1. Your Cassandra Related Dependency Beans and Listeners associated with it.
  2. Test Embedded Cassandra
  3. Test Cassandra Dataset usually loaded in .sql file.
  4. Test classpath, ldap and any properties needed.

NOTE: This is just a context test for that particular instance being ran at that time. Passing this does not guarantee that it will behave the same in a different environments. This is just a basic level check to see if at least the coding side of things are correct.

@RunWith(SpringRunner.class)
@TestExecutionListeners(listeners = {
    YourCassandraRelatedDependencyListeners.class})
@CassandraDataSet(value = {
    "/setup.cql"}, keyspace = "your-defined-space")
@EmbeddedCassandra(timeout = 50000L)
@SpringBootTest(classes = {
    YourApplication.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
        "spring.cloud.config.label=integration-test"})
@TestPropertySource(locations = {
    "classpath:embeddedCassandra.properties",
    "classpath:krypt.properties",
    "classpath:ldap.properties"})
@Category(value = IntegrationTest.class)
public class YourApplicationIT
{
    @Test
    public void contextLoad()
    {
    }
}

Posted

in

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *