我有这样的设置:
class PriceAwareSpec extends Specification {
sequential
running(FakeApplication()) {
val price = "CHF 50.00"
val priceAsHtml: Html = Html(price)
val context: Context = ContextAccessUtil.getContext
val stateAccess = ServiceFactoryUtil.getService(context, classOf[StateAccess])
"price aware template" should {
"per default" in {
stateAccess.store(StateKeys.HIDE_NETTO_KEY, java.lang.Boolean.FALSE)
"show netto" in {
val html = views.html.price.priceAware(priceAsHtml, true)(request)
contentAsString(html) must contain(price)
}
"show brutto" in {
val html = views.html.price.priceAware(priceAsHtml, false)(request)
contentAsString(html) must contain(price)
}
}
}
}
随着调用
ContextAccessUtil.getContext
有一个访问播放缓存的权限
play.cache.Cache.get("foo")
它确实尝试从当前应用程序中获取信息(=FakeApplication() ?)
这会导致 NullPointerException:
[error] NullPointerException: null (Cache.scala:-1)
[error] play.api.cache.Cache$.get(Cache.scala:57)
[error] play.api.cache.Cache.get(Cache.scala)
[error] play.cache.Cache.get(Cache.java:16)
这表明没有应用程序存在......?!
我的设置有问题吗?