}
public void testMoreThanOneFetchPersistentState() throws Exception
{
CacheLoaderManager mgr = new CacheLoaderManager();
CacheLoaderConfig cfg = createCacheLoaderCfg(false);
CacheLoaderConfig.IndividualCacheLoaderConfig i = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i.setFetchPersistentState(true);
CacheLoaderConfig.IndividualCacheLoaderConfig i2 = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i2.setFetchPersistentState(true);
cfg.addIndividualCacheLoaderConfig(i);
cfg.addIndividualCacheLoaderConfig(i2);
assertEquals(2, cfg.getIndividualCacheLoaderConfigs().size());
try
{
mgr.setConfig(cfg, null, null);
assertTrue("Should throw exception since we have > 1 cache loader with fetchPersistentState as true", false);
}
catch (Exception e)
{
assertTrue(true);
}
// control cases which should not throw exceptions
mgr = new CacheLoaderManager();
cfg = createCacheLoaderCfg(false);
i = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i.setFetchPersistentState(true);
cfg.addIndividualCacheLoaderConfig(i);
assertEquals(1, cfg.getIndividualCacheLoaderConfigs().size());
mgr.setConfig(cfg, null, null);
// control cases which should not throw exceptions
mgr = new CacheLoaderManager();
cfg = createCacheLoaderCfg(false);
i = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i.setFetchPersistentState(true);
i2 = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i2.setFetchPersistentState(false);
cfg.addIndividualCacheLoaderConfig(i);
cfg.addIndividualCacheLoaderConfig(i2);
assertEquals(2, cfg.getIndividualCacheLoaderConfigs().size());
mgr.setConfig(cfg, null, null);
// control cases which should not throw exceptions
mgr = new CacheLoaderManager();
cfg = createCacheLoaderCfg(false);
i = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i.setFetchPersistentState(false);
i2 = createIndividualCacheLoaderConfig(cfg, true, "org.jboss.cache.loader.FileCacheLoader");
i2.setFetchPersistentState(false);
cfg.addIndividualCacheLoaderConfig(i);
cfg.addIndividualCacheLoaderConfig(i2);
assertEquals(2, cfg.getIndividualCacheLoaderConfigs().size());
mgr.setConfig(cfg, null, null);
}