2014-02-07 41 views
0

我正在研究其大部分Junit失敗的項目。我的工作是解決它們並讓它們運行。我已經修復了大約200個Junit課程,但是大約有136個Junit仍然失敗,沒有理念,有時他們會失敗,有些他們工作。嘗試深入研究這個問題,並查看ehCache。它正在關機。CacheManager.clearAll拋出CacheManager已關閉Junit程序

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

我想通了哪裏出了問題。 Junit之一正在花時間完成,它是一個DAO。該方法需要大約40到50分鐘才能完成AND,並且會話超時緩存管理器發生,而當其他Junit嘗試訪問時,我得到該錯誤。 我修復了Junit意味着基本上DAO的查詢運行得更快,並且所有工作都很好。

+4

** 50 * MINUTES ***? DAO在做什麼,重建Google的數據庫索引? O_O –

0

你的代碼的某些部分被關閉的高速緩存管理器(可能在撕裂的單元測試下),然後試圖清除緩存。你可以在堆棧跟蹤看到這一點:

at net.sf.ehcache.CacheManager.clearAll(CacheManager.java:1526) 

但是一旦管理器關機,你不能在它調用操作。沒有看到單元測試的代碼,它很難更具體。

+0

無法確定正在做這件事的確切類。但有時它有效(意思是所有的Junits都通過了。)。只是想知道,如果clearAll被稱爲一個Junit測試,另一個Junit測試也會這樣做,那會導致這個問題。 – Kumar

相關問題