I have a class that stores a value in redis. When i test it, it works properly. If i run it for the second tome it will fail as there is an entry on redis already. I want to cleanup the redis database before running the test and after it is finished but i haven't been able to do that.
I am running grails 2.2.4.
I have tried the @autowired
annotation,@mock(RedisService)
, also redisService = grails.util.Holders.applicationContext.getBean('redisService') as RedisService
and i am not able to create an instance of the redisService.
This is what i am trying to do:
redisService.withRedis { Jedis redis -> redis.del("test") }
The expected result would be that the entry is deleted from redis.
I have gotten several errors like:java.lang.NullPointerException: Cannot get property 'resource' on null objectandjava.lang.IllegalArgumentException: ServletContext must not be null
Any help would be appreciated.