Spring 3.2 disable @Cacheable during unit tests

I'm facing a problem with my unit tests. I currently use ehcache whith spring 3.2 (@Cacheable) everything works well but i would like to disable the cache during my unit tests.

So in src/test/resources/ehcache.xml i wrote :

<cache name="myCache"
       maxElementsInMemory="1"
       eternal="false"
       timeToIdleSeconds="0"
       timeToLiveSeconds="0"
       overflowToDisk="true"
       maxElementsOnDisk="0"
       diskPersistent="false"
       diskExpiryThreadIntervalSeconds="0"
       memoryStoreEvictionPolicy="LRU"/>

but the cache still working ! Is anyone has an idea ?

Thanks in advance for your help!

Answers


Spring profile is done for that purpose. See documentation here, here.

Define a profile "test" in your cache manager bean (<bean profile="test" ... />) or upper and activate or not this profile with annotation @ActiveProfiles("test").

If your problem persists, verify that the context which defines the cache is the root context.


Need Your Help

RDiscount :generate_toc with Sinatra

ruby sinatra markdown tilt rdiscount

So I have sinatra setup with Rdiscount to render a markdown file with a HAML layout. This all works but I want RDiscount to generate a table of contents based on the headers in my haml file. I've t...

Format date in "M d, yy"

javascript jquery jquery-ui

I want to format newDate in format Dec 24, 2013 which is currently like