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
.taxeditor
.remoting
.cache
.CdmClientCacheException
;
16 import eu
.etaxonomy
.taxeditor
.remoting
.cache
.CdmModelCacher
;
17 import eu
.etaxonomy
.taxeditor
.remoting
.cache
.CdmModelFieldPropertyFromClass
;
18 import eu
.etaxonomy
.taxeditor
.remoting
.cache
.CdmRemoteCacheManager
;
19 import eu
.etaxonomy
.taxeditor
.remoting
.cache
.CdmRemoteCacheManager
.CdmCacheManagerType
;
22 public class CdmModelGetMethodCacherTest
{
24 private static final Logger logger
= Logger
.getLogger(CdmModelGetMethodCacherTest
.class);
26 public static final Resource CDMLIB_DISK_STORE_RESOURCE
=
27 new ClassPathResource("/eu/etaxonomy/cache");
32 public void cacheGettersTest() {
34 Logger
.getRootLogger().setLevel(Level
.INFO
);
36 System
.setProperty("ehcache.disk.store.dir", CDMLIB_DISK_STORE_RESOURCE
.getFile().getAbsolutePath());
37 } catch (IOException e
) {
38 throw new CdmClientCacheException(e
);
40 CdmModelCacher cmdmc
= new CdmModelCacher();
42 //cmdmc.checkGetterMethods();
44 cmdmc
.cacheGetterFields();
47 Cache cdmlibCache
= CdmRemoteCacheManager
.getInstance().getCdmModelGetMethodsCache();
48 List
<CdmModelFieldPropertyFromClass
> cmgmfcList
= cmdmc
.getCdmModelGetMethodFromClassList();
50 List
<Object
> keys
= cdmlibCache
.getKeys();
51 Assert
.assertEquals(cmgmfcList
.size(), keys
.size());
53 for(CdmModelFieldPropertyFromClass cmgmfc
: cmgmfcList
) {
54 String className
= cmgmfc
.getClassName();
55 Assert
.assertTrue(keys
.contains(className
));
56 logger
.info("Class Name : " + className
+ " has been cached");
58 cdmlibCache
.removeAll();
60 CdmRemoteCacheManager
.getInstance().shutdown(CdmCacheManagerType
.CDMLIB_MODEL
);