title: Play! Scala 2.5 : testing classes injecting cache leads to an error
body: <p>I'm using for the first time the cache of Play! Scala 2.5. It works well except for the tests. </p>
  
  <p>My test still pass since I don't need the cache but I get this error (and a lot of others telling the same thing): </p>
  
  <pre><code>Unable to provision, see the following errors:
  
  1) Error in custom provider, play.api.cache.EhCacheExistsException: An EhCache instance with name 'play' already exists.
  </code></pre>
  
  <p>I understand the error but I didn't manage to implement my own version of the cache API (to mock it).</p>
  
  <p>I tried to do what is told on the <a href="https://groups.google.com/d/topic/play-framework/PBIfeiwl5rU/discussion" rel="noreferrer">play mailing list</a> but without success (there is some differences with Play! 2.4 since the module is dependency injected). Any help would be welcome.</p>
  
  <p><strong>Edit:</strong> what I have done (and it does not change anything):</p>
  
  <p>My CacheApi version (just for the tests):</p>
  
  <pre><code>class MyCacheApi extends CacheApi {
    lazy val cache = {
      val manager = CacheManager.getInstance()
      manager.addCacheIfAbsent("play")
      manager.getCache("play")
    }
  
    def set(key: String, value: Any, expiration: Duration = Duration.Inf) = {}
  
    def remove(key: String) = {}
  
    def getOrElse[A: ClassTag](key: String, expiration: Duration = Duration.Inf)(orElse: =&gt; A): A = {
      get[A](key).getOrElse {
        val value = orElse
        set(key, value, expiration)
        value
      }
    }
  
    def get[T: ClassTag](key: String): Option[T] = None
  }
  </code></pre>
  
  <p>And in my tests, I use it like this:</p>
  
  <pre><code>lazy val appBuilder = new GuiceApplicationBuilder()
      .in(Mode.Test)
      .overrides(bind[CacheApi].to[MyCacheApi])
  
  lazy val injector = appBuilder.injector()
  lazy val cache = new MyCacheApi
  lazy val facebookAPI = new FacebookAPI(cache)
  </code></pre>
  
  <p>But when I'm testing the functions of the class <code>FacebookAPI</code>, the tests pass, but I still have a lot of error messages due to the fact that an EhCache instance with name 'play' already exists...</p>