cassandra-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andre Sprenger <>
Subject Re: How to tear down an EmbeddedCassandraService in unit tests?
Date Fri, 28 Mar 2014 19:05:13 GMT
We are using version 1.2.4 and it is difficult to shutdown the embedded
version. But you don't have to. Just check in each test setup method if
embedded Cassandra is already running and start it if necessary. Than
create keyspaces/tables in setup methods and drop them in teardown methods.
For us this is also faster.

A nice alternative is:

We also use Farsandra and it works pretty well.

2014-03-28 18:10 GMT+01:00 Clint Kelly <>:

> All,
> I have a question about how to use the EmbeddedCassandraService in unit
> tests.  I wrote a short collection of unit tests here:
> I'm trying to start up a new EmbeddedCassandraService for each unit test.
> I looked at the Cassandra source code to try to see how that happens there
> and replicated it as well as I could here.  My first unit test works great,
> but in subsequent unit tests I get this error:
> java.lang.RuntimeException:
> target/cassandra/data/system/schema_keyspaces/system-schema_keyspaces-jb-2-Data.db
> (No such file or directory)
> I assume that this is because I am not shutting down the
> EmbeddedCassandraService in the first unit test correctly (I do not have
> any @After method).
> Does anyone have any advice on how to clean up the
> EmbeddedCassandraService between unit tests?  I can instead create the
> EmbeddedCassandraService in a static @BeforeClass method and then have
> every unit test use a different keyspace, but that strikes me as somewhat
> sloppy and I'd rather understand what I'm doing well enough to be able to
> have one service per test if necessary.
> Thanks!
> Best regards,
> Clint

View raw message