Closed Donnerbart closed 2 years ago
Based on the current standard the current implementations have the guarantee that the CachingProvider
is only created once during JVM lifetime. Adding a Caching.clear()
as you suggest, would break that assumption. That may or may not work across all implementations. Besides, testing this behavior in the TCK would be very difficult.
During a normal application run, there is no use in redefining the default caching provider midway. If your tests need to run with different providers, its best to specify them explicitly.
Opting for closing this issue.
API Change so 2.0
The class
Caching
is missing a cleanup method to ease the testing of JCache.In our project we have multiple
CachingProvider
implementations (e.g. a server and client implementation). If we run the server and client tests in the same JVM, theCachingProvider
from the first invoked test remains in the internalCachingProviderRegistry
. This crashes the following tests, since we either get the wrongCachingProvider
viaCaching.getCachingProvider()
or we run into thisCacheException
:Closing the
CachingProvider
doesn't help, since the spec defines that it will be re-used, not removed.A nice way to solve this would be a
Caching.clear()
orCaching.destroy()
method. At the moment we are solving this issue with this nasty helper method: