mardi 27 novembre 2018

Unit Testing Using embedded Cassandra in Spring Boot

I am trying to test a Spring Boot Application which includes saving into cassandra DB. For unit testing I used EmbeddedCassandra.

These are the dependencies.

compile group: "com.datastax.cassandra", name: "cassandra-driver-core", version:"2.1.7"
    compile group: "com.datastax.cassandra", name: "cassandra-driver-dse", version:"2.1.7"
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile  ("org.cassandraunit:cassandra-unit-spring:2.1.9.2"){
        exclude group:"org.cassandraunit",module:"cassandra-unit"
    }

These are annotations I have used

@RunWith(SpringRunner.class)
@WebMvcTest(value = MyController.class)
@Import(value = {MyDao.class})
@ContextConfiguration
@TestExecutionListeners(listeners = {
        CassandraUnitDependencyInjectionTestExecutionListener.class,
        CassandraUnitTestExecutionListener.class,
        ServletTestExecutionListener.class,
        DependencyInjectionTestExecutionListener.class,
        DirtiesContextTestExecutionListener.class}
)
@EmbeddedCassandra(timeout = 60000)
@CassandraDataSet(keyspace = "test", value = {"test.cql"})

But the values saved in unit testing is populated original cassandra db . Can anyone help me to resolve this?

Aucun commentaire:

Enregistrer un commentaire