use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testPersistentPartition.
/**
* Make sure you can create a persistent partitioned region from xml.
*/
@Test
public void testPersistentPartition() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
cache.createRegion("parRoot", attrs);
Region r = cache.getRegion("parRoot");
assertEquals(DataPolicy.PERSISTENT_PARTITION, r.getAttributes().getDataPolicy());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region region = c.getRegion("parRoot");
assertNotNull(region);
assertEquals(DataPolicy.PERSISTENT_PARTITION, region.getAttributes().getDataPolicy());
// since CacheTestCase remoteTearDown does not destroy PartitionedRegion
region.localDestroyRegion();
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation 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.RegionAttributesCreation 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.RegionAttributesCreation 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.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testDynamicRegionFactoryDefault.
/**
* @since GemFire 4.3
*/
@Test
public void testDynamicRegionFactoryDefault() throws Exception {
CacheCreation cache = new CacheCreation();
cache.setDynamicRegionFactoryConfig(new DynamicRegionFactory.Config());
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
cache.createRegion("root", attrs);
// note that testXml can't check if they are same because enabling
// dynamic regions causes a meta region to be produced.
testXml(cache, false);
assertEquals(true, DynamicRegionFactory.get().getConfig().getRegisterInterest());
assertEquals(true, DynamicRegionFactory.get().getConfig().getPersistBackup());
assertEquals(true, DynamicRegionFactory.get().isOpen());
assertEquals(null, DynamicRegionFactory.get().getConfig().getDiskDir());
Region dr = getCache().getRegion("__DynamicRegions");
if (dr != null) {
dr.localDestroyRegion();
}
}
Aggregations