【发布时间】:2013-11-19 03:40:37
【问题描述】:
当我运行我的测试时,这个错误会在第一次测试后立即抛出。我猜这是因为 Play 使用的是 CacheManager.create(ehcacheXml),它只为每个应用程序创建一个实例。
[error] IllegalStateException: The play Cache is not alive (STATUS_SHUTDOWN) (Cache.java:4267)
如何配置play以使用多实例ehcache?
这是我的测试:
abstract class WithCleanTestData extends WithApplication(FakeApplication(
additionalConfiguration = TestConf.getConf.toMap
)) {
override def around[T: AsResult](t: => T): Result = super.around {
prepareDbWithData()
t
}
def prepareDbWithData() = {
}
}
object MyTest extends PlaySpecification {
"test api" should {
class MyCtrl() extends Controller with MyControler
"post data 1" in new WithCleanTestData {
val myControler = new MyCtrl()
val ret: Future[SimpleResult] = myControler.method().apply(FakeRequest())
.....
}
"post data 2" in new WithCleanTestData {
val myControler = new MyCtrl()
val ret: Future[SimpleResult] = myControler.method().apply(FakeRequest())
.....
}
}
}
【问题讨论】:
标签: scala playframework ehcache playframework-2.1 playframework-2.2