我正在研究Junit的大部分失败的项目。我的工作是修复它们并使它们运行。我已经修复了大约200个Junit类,但是大约有136个Junits仍然失败,原因没有想法,有时候他们会失败,有些人会工作。尝试深入研究问题,然后是ehCache。它正在关闭。
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)
答案 0 :(得分:0)
您的代码的某些部分正在关闭缓存管理器(可能是在拆除单元测试时),然后尝试清除缓存。您可以在堆栈跟踪中看到这一点:
at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526)
但是一旦管理员关闭,你就无法调用它。没有看到其中一个单元测试的代码,很难更具体。
答案 1 :(得分:0)
我弄清楚出了什么问题。其中一个Junit需要时间来完成,它是一个DAO。该方法需要大约40到50分钟才能完成并且会话超时缓存管理器会发生,而当其他Junit尝试访问时我会收到该错误。 我修复了Junit基本上意味着DAO的查询运行得更快,一切运行良好。