* @throws Exception
*/
@SuppressWarnings({"rawtypes", "unchecked"})
public void testDistributedCache() throws Exception
{
PortalContainer pc = PortalContainer.getInstance();
ExoCacheConfig config = new ExoCacheConfig();
config.setName("MyCacheDistributed");
config.setMaxSize(5);
config.setLiveTime(1);
config.setImplementation("LRU");
config.setDistributed(true);
Map<String, String> params = new HashMap<String, String>();
params.put("infinispan-num-owners", "1");
ConfigurationManager cm = (ConfigurationManager)pc.getComponentInstanceOfType(ConfigurationManager.class);
DistributedCacheManager dcm2 =
new DistributedCacheManager("jar:/conf/portal/distributed-cache-configuration.xml", params, cm);
DistributedExoCache<Serializable, Object> cache1 =
(DistributedExoCache<Serializable, Object>)((ExoCacheFactory)pc
.getComponentInstanceOfType(ExoCacheFactory.class)).createCache(config);
DistributionManager dm = cache1.getCache().getDistributionManager();
DistributedExoCache<Serializable, Object> cache2 =
(DistributedExoCache<Serializable, Object>)new ExoCacheFactoryImpl(
(ExoContainerContext)pc.getComponentInstanceOfType(ExoContainerContext.class),
"jar:/conf/portal/cache-configuration-template.xml", cm, dcm2).createCache(config);
KeyAffinityService kas1 =
KeyAffinityServiceFactory.newLocalKeyAffinityService(cache1.getCache(),
new MyKeyGenerator(cache1.getFullName()), Executors.newSingleThreadExecutor(), 100);
KeyAffinityService kas2 =