jsevellec / cassandra-unit

Utility tool to load Data into Cassandra to help you writing good isolated JUnit Test into your application
GNU Lesser General Public License v3.0
425 stars 0 forks source link

Add a parameter takes the path of application.conf for CqlSession #310

Open t2y opened 4 years ago

t2y commented 4 years ago

According to DataStax Java Driver 4.3 Configuration, Cassandra driver uses Typesafe Config named application.conf over 4.x.

There are many options to be able to configure CqlSession and it's useful to pass any application.conf to EmbeddedCassandraServerHelper.getSession(confPath)) for testing.

Concern

I referred EmbeddedCassandraServerHelperTest and copied it, then I modified as EmbeddedCassandraServerHelperWithConfigLoaderTest. This test has @Ignore annotation and the test will be skipped.

To confirm my change is correct, I just commented out @Ignore annotation when I test, then run test command as below. Is this an appropriate way to run ignored tests?

$ mvn test -DfailIfNoTests=false -Dtest=EmbeddedCassandraServerHelperWithConfigLoaderTest
t2y commented 4 years ago

I made a workaround to recreate CqlSession takes parameters: an address from a session returned by cassandra-unit, fixed datacenter string and a configLoader reading any configuration file.

Of course, it works. But still, it's better for simplicity to pass any configuration file to cassandra-unit.

https://github.com/t2y/cassandra-driver-sample/blob/master/src/test/java/sample/cassandra/client/RateBasedRequestThrottlingTest.java