1 package eu
.etaxonomy
.cdm
.api
.cache
;
3 import java
.io
.IOException
;
6 import net
.sf
.ehcache
.Cache
;
8 import org
.apache
.log4j
.Level
;
9 import org
.apache
.log4j
.Logger
;
10 import org
.junit
.Assert
;
11 import org
.junit
.Test
;
12 import org
.springframework
.core
.io
.ClassPathResource
;
13 import org
.springframework
.core
.io
.Resource
;
15 import eu
.etaxonomy
.cdm
.api
.cache
.CdmRemoteCacheManager
.CdmCacheManagerType
;
18 public class CdmModelGetMethodCacherTest
{
20 private static final Logger logger
= Logger
.getLogger(CdmModelGetMethodCacherTest
.class);
22 public static final Resource CDMLIB_DISK_STORE_RESOURCE
=
23 new ClassPathResource("/eu/etaxonomy/cache");
28 public void cacheGettersTest() {
30 Logger
.getRootLogger().setLevel(Level
.INFO
);
32 System
.setProperty("ehcache.disk.store.dir", CDMLIB_DISK_STORE_RESOURCE
.getFile().getAbsolutePath());
33 } catch (IOException e
) {
34 throw new CdmClientCacheException(e
);
36 CdmModelCacher cmdmc
= new CdmModelCacher();
38 //cmdmc.checkGetterMethods();
40 cmdmc
.cacheGetterFields();
43 Cache cdmlibCache
= CdmRemoteCacheManager
.getInstance().getCdmModelGetMethodsCache();
44 List
<CdmModelFieldPropertyFromClass
> cmgmfcList
= cmdmc
.getCdmModelGetMethodFromClassList();
46 List
<Object
> keys
= cdmlibCache
.getKeys();
47 Assert
.assertEquals(cmgmfcList
.size(), keys
.size());
49 for(CdmModelFieldPropertyFromClass cmgmfc
: cmgmfcList
) {
50 String className
= cmgmfc
.getClassName();
51 Assert
.assertTrue(keys
.contains(className
));
52 logger
.info("Class Name : " + className
+ " has been cached");
54 cdmlibCache
.removeAll();
56 CdmRemoteCacheManager
.getInstance().shutdown(CdmCacheManagerType
.CDMLIB_MODEL
);