首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CacheManager.clearAll抛出CacheManager已关闭Junit程序

CacheManager.clearAll抛出CacheManager已关闭Junit程序
EN

Stack Overflow用户
提问于 2014-02-07 12:12:24
回答 2查看 4.5K关注 0票数 0

我正在做一个项目,它的大部分Junit都失败了。我的工作是修理它们并让它们运行。我已经修正了大约200个Junit类,但是仍然有大约136个Junit失败,原因是不知道,有时它们会失败,有些会工作。试着钻研这个问题,它就是ehCache。它被关闭了。

代码语言:javascript
复制
Can any body please explain me why this exception occur in Junt testing and that to not all the time. 
Please Note we have test cases for "Action" classes as well(Which deal with Servlet Context)
But interesting point all action test classes are getting passed.

Error Message is :
   java.lang.IllegalStateException: The CacheManager has been shut down. It can no longer be used.
    at net.sf.ehcache.CacheManager.checkStatus(CacheManager.java:1504)
    at net.sf.ehcache.CacheManager.getCacheNames(CacheManager.java:1491)
    at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526)
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-02-10 09:30:18

我知道出了什么问题。其中一个Junit需要时间来完成,这是一个DAO。该方法大约需要40到50分钟才能完成,而缓存管理器发生时会话超时,而当其他Junit试图访问时,我将得到该错误。我修正了Junit,这基本上意味着对DAO的查询运行得更快,而且一切都很好。

票数 0
EN

Stack Overflow用户

发布于 2014-02-07 12:34:19

代码的某些部分是关闭缓存管理器(可能是在单元测试的拆卸中),然后试图清除缓存。您可以在堆栈跟踪中看到这一点:

代码语言:javascript
复制
at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526)

但是,一旦管理器关闭,您就不能调用对它的操作。如果没有看到其中一个单元测试的代码,就很难更加具体。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21627479

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档