use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testDiskStoreValidation.
@Test
public void testDiskStoreValidation() throws Exception {
CacheCreation cache = new CacheCreation();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
DiskStore ds1 = dsf.create(getUniqueName());
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.REPLICATE);
attrs.setDiskStoreName(getUniqueName());
RegionCreation root;
try {
root = (RegionCreation) cache.createRegion("root", attrs);
fail("Expected IllegalStateException to be thrown");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_IS_USED_IN_NONPERSISTENT_REGION.toLocalizedString()));
}
EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1000, EvictionAction.OVERFLOW_TO_DISK);
attrs.setEvictionAttributes(ea);
root = (RegionCreation) cache.createRegion("root", attrs);
File dir = new File("testDiskStoreValidation");
dir.mkdir();
dir.deleteOnExit();
File[] dirs2 = new File[] { dir, new File("").getAbsoluteFile() };
try {
AttributesFactory factory = new AttributesFactory();
factory.setDiskDirs(dirs2);
factory.setDiskStoreName(getUniqueName());
RegionAttributes ra = factory.create();
fail("Expected IllegalStateException to be thrown");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setDiskDirs or setDiskWriteAttributes", getUniqueName())));
}
try {
AttributesFactory factory = new AttributesFactory();
factory.setDiskStoreName(getUniqueName());
factory.setDiskDirs(dirs2);
RegionAttributes ra = factory.create();
fail("Expected IllegalStateException to be thrown");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains(LocalizedStrings.DiskStore_Deprecated_API_0_Cannot_Mix_With_DiskStore_1.toLocalizedString("setDiskDirs", getUniqueName())));
}
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testBridgeMaxThreads.
/**
* Tests the bridge-server attributes ({@code max-threads}
*/
@Test
public void testBridgeMaxThreads() throws Exception {
CacheCreation cache = new CacheCreation();
CacheServer bs = cache.addCacheServer();
bs.setMaxThreads(37);
bs.setMaxConnections(999);
bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setDataPolicy(DataPolicy.NORMAL);
cache.createVMRegion("rootNORMAL", attrs);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testEvictionLRUEntryAttributes.
@Test
public void testEvictionLRUEntryAttributes() throws Exception {
final String rName = getUniqueName();
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(80, EvictionAction.LOCAL_DESTROY));
cache.createRegion(rName, attrs);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testDefaultRecoveryDelayAttributes.
/**
* Tests that a region created with a named attributes set programmatically for recovery-delay has
* the correct attributes.
*/
@Test
public void testDefaultRecoveryDelayAttributes() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setTotalMaxMemory(500);
paf.setLocalMaxMemory(100);
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(-1, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
assertEquals(0, 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(-1, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
assertEquals(0, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testDefaultCache.
/**
* Tests creating a cache with the default lock-timeout, lock-lease, and search-timeout.
*/
@Test
public void testDefaultCache() throws Exception {
CacheCreation cache = new CacheCreation();
testXml(cache);
}
Aggregations