doanduyhai / Achilles

An advanced Java Object Mapper/Query DSL generator for Cassandra
http://achilles.archinnov.info
Apache License 2.0
241 stars 92 forks source link

Need a way to reset Statement cache for test #359

Closed rickdong closed 5 years ago

rickdong commented 5 years ago

Using AchillesTestResource, the way it current does is by using a static instance of StatementsCache. This could lead to issues when testing insertion / update on same entity type using different keyspaces because the insertions statements are kept in the static cache which has no way to reset.

How to reproduce:

   - TestClassA inserts and updates on EntityA using KeyspaceA
   - TestClassB inserts and updates on EntityA using KeyspaceB
   - TestClassB fails because the insertions will target for KeyspaceA (due to the stmt cache from TestClassA's run) while updates will target KeyspaceB
rickdong commented 5 years ago

Okay, I see a way around this:

build((c, s) -> ManagerFactoryBuilder.builder(c)
                            .withStatementsCache(new StatementsCache(...))

Good for now.