use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testPartitionedRegionInstantiation.
/**
* Tests that a region created with a named attributes has the correct attributes.
*
* This tests currently fails due to (what seem to me as) limitations in the XML generator and the
* comparison of the XML. I have run this test by hand and looked at the generated XML and there
* were no significant problems, however because of the limitations, I am disabling this test, but
* leaving the functionality for future comparisons (by hand of course).
*/
@Test
public void testPartitionedRegionInstantiation() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setLocalMaxMemory(4).setTotalNumBuckets(17).setTotalMaxMemory(8);
attrs.setPartitionAttributes(paf.create());
cache.createRegion("pRoot", attrs);
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testRedefineOfDefaultDiskStore.
@Test
public void testRedefineOfDefaultDiskStore() throws Exception {
CacheCreation cache = new CacheCreation();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setAutoCompact(!DiskStoreFactory.DEFAULT_AUTO_COMPACT);
DiskStore ds1 = dsf.create(DiskStoreFactory.DEFAULT_DISK_STORE_NAME);
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
AttributesFactory factory = new AttributesFactory(attrs);
RegionAttributes ra = factory.create();
RegionCreation root = (RegionCreation) cache.createRegion("root", ra);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
DiskStore ds2 = c.findDiskStore(DiskStoreFactory.DEFAULT_DISK_STORE_NAME);
assertNotNull(ds2);
assertEquals(ds1.getAutoCompact(), ds2.getAutoCompact());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml81DUnitTest method testLocatorInException.
/**
* Test {@link Locator} is used in {@link SAXParseException}. Exercises
* {@link XmlParser#setDocumentLocator(Locator)}
*
* @since GemFire 8.2
*/
@Test
public void testLocatorInException() throws Exception {
final String regionName = "testRegionExtension";
final CacheCreation cache = new CacheCreation();
final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
@SuppressWarnings("unchecked") Extensible<Region<?, ?>> region = (Extensible<Region<?, ?>>) cache.createRegion(regionName, attrs);
final MockRegionExtension extension = new MockRegionExtension("exception");
region.getExtensionPoint().addExtension(extension);
assertEquals(0, extension.beforeCreateCounter.get());
assertEquals(0, extension.onCreateCounter.get());
assertEquals(0, extension.getXmlGeneratorCounter.get());
IgnoredException.addIgnoredException("While reading Cache XML file");
try {
testXml(cache);
fail("Excepted CacheXmlException");
} catch (final CacheXmlException e) {
if (e.getCause() instanceof SAXParseException) {
assertTrue(((SAXParseException) e.getCause()).getLineNumber() > 0);
assertTrue(((SAXParseException) e.getCause()).getColumnNumber() > 0);
assertEquals("Value is 'exception'.", e.getCause().getMessage());
}
}
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXmlGeode10DUnitTest method testEnableOffHeapMemorySubRegionWithoutOffHeapMemoryThrowsException.
@SuppressWarnings({ "rawtypes", "deprecation", "unchecked" })
@Test
public void testEnableOffHeapMemorySubRegionWithoutOffHeapMemoryThrowsException() throws Exception {
final String rootRegionName = getUniqueName();
final String subRegionName = "subRegion";
final CacheCreation cache = new CacheCreation();
final RegionAttributesCreation rootRegionAttrs = new RegionAttributesCreation(cache);
assertEquals(false, rootRegionAttrs.getOffHeap());
final Region rootRegionBefore = cache.createRegion(rootRegionName, rootRegionAttrs);
assertNotNull(rootRegionBefore);
assertEquals(false, rootRegionBefore.getAttributes().getOffHeap());
final RegionAttributesCreation subRegionAttrs = new RegionAttributesCreation(cache);
subRegionAttrs.setOffHeap(true);
assertEquals(true, subRegionAttrs.getOffHeap());
final Region subRegionBefore = rootRegionBefore.createSubregion(subRegionName, subRegionAttrs);
assertNotNull(subRegionBefore);
assertEquals(true, subRegionBefore.getAttributes().getOffHeap());
IgnoredException.addIgnoredException(LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED.toLocalizedString("/" + rootRegionName + "/" + subRegionName));
try {
testXml(cache);
fail("Expected IllegalStateException to be thrown");
} catch (IllegalStateException e) {
// expected
final String msg = LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED.toLocalizedString("/" + rootRegionName + "/" + subRegionName);
assertEquals(msg, e.getMessage());
}
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXmlGeode10DUnitTest method testEnableOffHeapMemoryRootRegionWithoutOffHeapMemoryThrowsException.
@SuppressWarnings("rawtypes")
@Test
public void testEnableOffHeapMemoryRootRegionWithoutOffHeapMemoryThrowsException() throws Exception {
final String regionName = getUniqueName();
final CacheCreation cache = new CacheCreation();
final RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setOffHeap(true);
assertEquals(true, attrs.getOffHeap());
final Region regionBefore = cache.createRegion(regionName, attrs);
assertNotNull(regionBefore);
assertEquals(true, regionBefore.getAttributes().getOffHeap());
IgnoredException.addIgnoredException(LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED.toLocalizedString("/" + regionName));
try {
testXml(cache);
fail("Expected IllegalStateException to be thrown");
} catch (IllegalStateException e) {
// expected
String msg = LocalizedStrings.LocalRegion_THE_REGION_0_WAS_CONFIGURED_TO_USE_OFF_HEAP_MEMORY_BUT_OFF_HEAP_NOT_CONFIGURED.toLocalizedString("/" + regionName);
assertEquals(msg, e.getMessage());
}
}
Aggregations