Tuesday, June 25, 2013

cassandra-unit is out : CQL3 script support and spring integration

I'm pleased to announce the release of cassandra-unit

Just as a reminder, cassandra-unit is a library to help you to start and load different type of dataset into an embedded Cassandra instance. Basically, the goal is to simplify the implementation of your unit tests in java.

There are 2 main new features in this release :
  • the support of CQL3 script as a standard cassandra-unit dataset.
  • the spring extension of cassandra-unit.

CQL3 support : embracing the new datamodel face of Cassandra

As you may know (or not ;-)) , the 1.2 version of Cassandra was released with major changes and a new remote protocol : binary CQL protocol. The main idea is with with new protocol is to get rid of some limitation with the Thrift protocol.

So with this new protocol come : 
So, as a first step this new release of cassandra-unit provide the ability to use CQL3 script as dataset to load data into your cassandra instance (embedded or not).

It implied internally some big modifications using the java-driver instead of Hector for the CQL3 part.

here is an example of use : 
simple.cql : 

CQLScriptLoadTest.cql : 

thanks marcinszymaniuk for your contribution!

Spring extension 

The other interesting feature provided in this release is the spring integration. I mean the ability to to use cassandra-unit with the Spring TestContest framework based on annotation.

As documented here, there was 3 ways to integrate cassandra-unit in your tests :
  • the native approach
  • using the AbstractCassandraUnitTestCase or AbstractCassandraUnitCQLTestCase
  • using JUnit4 @Rule
The cassandra-unit-spring integration provide a new way to integrate cassandra-unit in your unit tests.

The documentation about the spring integration is here

Here is a small example : 

simple.cql : : 

Thanks Olivier for your contribution!

cassandra-unit is available through maven public repo and source code is available on github and the project is licensed under LGPL V3.0


Anonymous said...


@Autowired not working, if I use The cassandra-unit-spring:

@TestExecutionListeners({ CassandraUnitTestExecutionListener.class })


Jérémy Sevellec said...

@anonyme : could you please repot the bug here :