use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testCacheListener.
/**
* Tests a cache listener with no parameters
*/
@Test
public void testCacheListener() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
CacheListener listener = new MyTestCacheListener();
attrs.setCacheListener(listener);
cache.createRegion("root", attrs);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testAlreadyExistingPool.
@Test
public void testAlreadyExistingPool() throws Exception {
getSystem();
PoolFactoryImpl f = (PoolFactoryImpl) PoolManager.createFactory();
f.setStartDisabled(true).addLocator(ALIAS2, 12345).create("mypool");
try {
// now make sure declarative cache can't create the same pool
CacheCreation cache = new CacheCreation();
cache.createPoolFactory().addLocator(ALIAS2, 12345).create("mypool");
IgnoredException expectedException = IgnoredException.addIgnoredException(LocalizedStrings.PoolManagerImpl_POOL_NAMED_0_ALREADY_EXISTS.toLocalizedString("mypool"));
try {
testXml(cache);
fail("expected IllegalStateException");
} catch (IllegalStateException expected) {
} finally {
expectedException.remove();
}
} finally {
PoolManager.close();
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testCreateSameRegionTwice.
/**
* Tests to make sure that we cannot create the same region multiple times in a {@code cache.xml}
* file.
*/
@Test
public void testCreateSameRegionTwice() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
String name = "root";
cache.createRegion(name, attrs);
try {
cache.createRegion(name, attrs);
fail("Should have thrown a RegionExistsException");
} catch (RegionExistsException ex) {
// pass...
}
setXmlFile(findFile("sameRootRegion.xml"));
IgnoredException expectedException = IgnoredException.addIgnoredException("While reading Cache XML file");
try {
getCache();
fail("Should have thrown a CacheXmlException");
} catch (CacheXmlException ex) {
Throwable cause = ex.getCause();
assertTrue(cause instanceof SAXException);
cause = ((SAXException) cause).getException();
if (!(cause instanceof RegionExistsException)) {
Assert.fail("Expected a RegionExistsException, not a " + cause.getClass().getName(), cause);
}
} finally {
expectedException.remove();
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testCacheLoaderWithDeclarables.
/**
* Tests a cache loader an interesting combination of declarables
*/
@Test
public void testCacheLoaderWithDeclarables() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
CacheLoaderWithDeclarables loader = new CacheLoaderWithDeclarables();
attrs.setCacheLoader(loader);
cache.createRegion("root", attrs);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testBackupFiles.
@Test
public void testBackupFiles() throws Exception {
CacheCreation cache = new CacheCreation();
File backup1 = new File("/back/me/up");
File backup2 = new File("/me/too/please");
cache.addBackup(backup1);
cache.addBackup(backup2);
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
assertEquals(Arrays.asList(new File[] { backup1, backup2 }), c.getBackupFiles());
}
Aggregations