Revision f4142aa7
Added by Cherian Mathew almost 9 years ago
eu.etaxonomy.taxeditor.test/src/test/java/eu/etaxonomy/cdm/api/cache/CdmModelGetMethodCacherTest.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.api.cache; |
2 | 2 |
|
3 |
import java.io.IOException; |
|
4 | 3 |
import java.util.List; |
5 | 4 |
|
6 | 5 |
import net.sf.ehcache.Cache; |
6 |
import net.sf.ehcache.CacheManager; |
|
7 | 7 |
|
8 |
import org.apache.log4j.Level; |
|
9 | 8 |
import org.apache.log4j.Logger; |
10 | 9 |
import org.junit.Assert; |
11 | 10 |
import org.junit.Test; |
12 |
import org.springframework.core.io.ClassPathResource; |
|
13 |
import org.springframework.core.io.Resource; |
|
14 | 11 |
|
15 |
import eu.etaxonomy.taxeditor.remoting.cache.CdmClientCacheException; |
|
16 | 12 |
import eu.etaxonomy.taxeditor.remoting.cache.CdmModelCacher; |
17 | 13 |
import eu.etaxonomy.taxeditor.remoting.cache.CdmModelFieldPropertyFromClass; |
18 | 14 |
import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager; |
19 |
import eu.etaxonomy.taxeditor.remoting.cache.CdmRemoteCacheManager.CdmCacheManagerType; |
|
20 | 15 |
|
21 | 16 |
|
22 | 17 |
public class CdmModelGetMethodCacherTest { |
23 | 18 |
|
24 | 19 |
private static final Logger logger = Logger.getLogger(CdmModelGetMethodCacherTest.class); |
25 | 20 |
|
26 |
public static final Resource CDMLIB_DISK_STORE_RESOURCE = |
|
27 |
new ClassPathResource("/eu/etaxonomy/cache"); |
|
28 |
|
|
29 |
|
|
30 | 21 |
|
31 | 22 |
@Test |
32 | 23 |
public void cacheGettersTest() { |
33 |
|
|
34 |
Logger.getRootLogger().setLevel(Level.INFO); |
|
35 |
try { |
|
36 |
System.setProperty("ehcache.disk.store.dir", CDMLIB_DISK_STORE_RESOURCE.getFile().getAbsolutePath()); |
|
37 |
} catch (IOException e) { |
|
38 |
throw new CdmClientCacheException(e); |
|
39 |
} |
|
24 |
|
|
40 | 25 |
CdmModelCacher cmdmc = new CdmModelCacher(); |
41 |
|
|
42 |
//cmdmc.checkGetterMethods(); |
|
43 |
|
|
44 |
cmdmc.cacheGetterFields(); |
|
45 | 26 |
|
46 |
|
|
47 | 27 |
Cache cdmlibCache = CdmRemoteCacheManager.getInstance().getCdmModelGetMethodsCache(); |
48 | 28 |
List<CdmModelFieldPropertyFromClass> cmgmfcList = cmdmc.getCdmModelGetMethodFromClassList(); |
49 |
|
|
29 |
|
|
50 | 30 |
List<Object> keys = cdmlibCache.getKeys(); |
51 | 31 |
Assert.assertEquals(cmgmfcList.size(), keys.size()); |
52 |
|
|
32 |
|
|
53 | 33 |
for(CdmModelFieldPropertyFromClass cmgmfc: cmgmfcList) { |
54 | 34 |
String className = cmgmfc.getClassName(); |
55 | 35 |
Assert.assertTrue(keys.contains(className)); |
56 | 36 |
logger.info("Class Name : " + className + " has been cached"); |
57 | 37 |
} |
58 | 38 |
cdmlibCache.removeAll(); |
59 |
cdmlibCache.flush(); |
|
60 |
CdmRemoteCacheManager.getInstance().shutdown(CdmCacheManagerType.CDMLIB_MODEL); |
|
39 |
CacheManager.create().shutdown(); |
|
61 | 40 |
} |
62 | 41 |
|
63 |
|
|
64 |
|
|
42 |
|
|
43 |
|
|
65 | 44 |
|
66 | 45 |
} |
Also available in: Unified diff
cdmlib-ehcache : removed disk based cache manager since the hb config is now cached in memory
CdmApplicationRemoteController, CdmModelCacher, CdmRemoteCacheManager, CdmModelGetMethodCacherTest : running the hibernate config load in separate thread
CdmTransientEntityCacher, EntityCacherDebugResult, CdmStore, SessionsViewPart: refactoring
httpInvokerServiceClients.xml : removed lazy loading of beans