NoSQL Zone is brought to you in partnership with:

Wille Faler is an experienced software developer, architect and agile coach with experience across a number of different industries as an independent consultant. Wille specializes in backend, integration, and Java technologies, but has more recently found a passion for Scala and text mining/analysis. Wille is a DZone MVB and is not an employee of DZone and has posted 42 posts at DZone. You can read more from them at their website. View Full User Profile

Curious about Cassandra DB Unit Testing? Here's a Tip...

04.26.2012
| 3532 views |
  • submit to reddit
If you’re curious about Cassandra DB, but don’t quite know how to run it with unit-tests, here’s a little tip for you. Below is a simplistic Scala code-snippet that will start Cassandra as an embedded service (unless it is already running) and pick up the Cassandra configs from your src/test/resources directory (you’ll want your storage-conf.xml and log4j.properties there):

Now you can just start Cassandra by calling EmbeddedCassandraService.start, and a new server process will start unless one is already running.

I found the starts of this snippet on the web, I can’t remember where, but I believe it was in the Akka source code, and I just took it and adapted it a little to work better in my workspace..

Below is the CassandraClient convenience class that I have created and that is used in the sample:

 

Published at DZone with permission of Wille Faler, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags: