use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testIsLockGrantorAttribute.
/**
* Tests the is-lock-grantor attribute in xml.
*/
@Test
public void testIsLockGrantorAttribute() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setLockGrantor(true);
attrs.setScope(Scope.GLOBAL);
attrs.setMirrorType(MirrorType.KEYS_VALUES);
cache.createRegion("root", attrs);
testXml(cache);
assertEquals(true, cache.getRegion("root").getAttributes().isLockGrantor());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testRecoveryDelayAttributes.
/**
* Tests that a region created with a named attributes set programatically for recovery-delay has
* the correct attributes.
*/
@Test
public void testRecoveryDelayAttributes() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setTotalMaxMemory(500);
paf.setLocalMaxMemory(100);
paf.setRecoveryDelay(33);
paf.setStartupRecoveryDelay(270);
attrs.setPartitionAttributes(paf.create());
cache.createRegion("parRoot", attrs);
Region r = cache.getRegion("parRoot");
assertEquals(r.getAttributes().getPartitionAttributes().getRedundantCopies(), 1);
assertEquals(r.getAttributes().getPartitionAttributes().getLocalMaxMemory(), 100);
assertEquals(r.getAttributes().getPartitionAttributes().getTotalMaxMemory(), 500);
assertEquals(33, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
assertEquals(270, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region region = c.getRegion("parRoot");
assertNotNull(region);
RegionAttributes regionAttrs = region.getAttributes();
PartitionAttributes pa = regionAttrs.getPartitionAttributes();
assertEquals(pa.getRedundantCopies(), 1);
assertEquals(pa.getLocalMaxMemory(), 100);
assertEquals(pa.getTotalMaxMemory(), 500);
assertEquals(33, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
assertEquals(270, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testEnableBridgeConflationAttribute.
/**
* Test EnableBridgeConflation region attribute
*
* @since GemFire 4.2
*/
@Test
public void testEnableBridgeConflationAttribute() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setEnableBridgeConflation(true);
cache.createRegion("root", attrs);
testXml(cache);
assertEquals(true, cache.getRegion("root").getAttributes().getEnableBridgeConflation());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testRegionMulticastSetViaCacheXml.
/**
* Tests that loading cache XML with multi-cast set will set the multi-cast
*/
@Test
public void testRegionMulticastSetViaCacheXml() throws Exception {
final String rNameBase = getUniqueName();
final String r1 = rNameBase + "1";
final String r2 = rNameBase + "2";
final String r3 = rNameBase + "3";
// Setting multi-cast via nested region attributes
CacheCreation creation = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(creation);
attrs.setScope(Scope.LOCAL);
attrs.setEarlyAck(false);
attrs.setMulticastEnabled(true);
creation.createRegion(r1, attrs);
// Setting multi-cast via named region attributes
final String attrId = "region_attrs_with_multicast";
attrs = new RegionAttributesCreation(creation);
attrs.setId(attrId);
attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
attrs.setEarlyAck(false);
attrs.setMulticastEnabled(true);
creation.setRegionAttributes(attrs.getId(), attrs);
attrs = new RegionAttributesCreation(creation);
attrs.setRefid(attrId);
creation.createRegion(r3, attrs);
testXml(creation);
creation = new CacheCreation();
attrs = new RegionAttributesCreation(creation);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setEarlyAck(false);
attrs.setMulticastEnabled(true);
creation.createRegion(r2, attrs);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
{
Region reg1 = c.getRegion(r1);
assertNotNull(reg1);
assertEquals(Scope.LOCAL, reg1.getAttributes().getScope());
assertFalse(reg1.getAttributes().getEarlyAck());
assertTrue(reg1.getAttributes().getMulticastEnabled());
}
{
Region reg2 = c.getRegion(r2);
assertNotNull(reg2);
assertEquals(Scope.DISTRIBUTED_ACK, reg2.getAttributes().getScope());
assertFalse(reg2.getAttributes().getEarlyAck());
assertTrue(reg2.getAttributes().getMulticastEnabled());
}
{
Region reg3 = c.getRegion(r3);
assertNotNull(reg3);
assertEquals(Scope.DISTRIBUTED_NO_ACK, reg3.getAttributes().getScope());
assertFalse(reg3.getAttributes().getEarlyAck());
assertTrue(reg3.getAttributes().getMulticastEnabled());
}
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testCreateSameSubregionTwice.
/**
* Tests to make sure that we cannot create the same subregion multiple times in a
* {@code cache.xml} file.
*/
@Test
public void testCreateSameSubregionTwice() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
String name = this.getUniqueName();
Region root = cache.createRegion("root", attrs);
root.createSubregion(name, attrs);
try {
root.createSubregion(name, attrs);
fail("Should have thrown a RegionExistsException");
} catch (RegionExistsException ex) {
// pass...
}
setXmlFile(findFile("sameSubregion.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();
}
}
Aggregations