use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testDiskStore.
@Test
public void testDiskStore() throws Exception {
CacheCreation cache = new CacheCreation();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
File[] dirs1 = new File[] { new File("").getAbsoluteFile() };
DiskStore ds1 = dsf.setAllowForceCompaction(true).setAutoCompact(true).setCompactionThreshold(100).setMaxOplogSize(2).setTimeInterval(10).setWriteBufferSize(15).setQueueSize(12).setDiskDirsAndSizes(dirs1, new int[] { 1024 * 20 }).create(getUniqueName() + 1);
File[] dirs2 = new File[] { new File("").getAbsoluteFile() };
DiskStore ds2 = dsf.setAllowForceCompaction(false).setAutoCompact(false).setCompactionThreshold(99).setMaxOplogSize(1).setTimeInterval(9).setWriteBufferSize(14).setQueueSize(11).setDiskDirsAndSizes(dirs2, new int[] { 1024 * 40 }).create(getUniqueName() + 2);
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
attrs.setDiskStoreName(getUniqueName() + 1);
attrs.setDiskSynchronous(true);
RegionCreation root = (RegionCreation) cache.createRegion("root", attrs);
{
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
attrs.setDiskStoreName(getUniqueName() + 2);
Region subwithdiskstore = root.createSubregion("subwithdiskstore", attrs);
}
{
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
Region subwithdefaultdiskstore = root.createSubregion("subwithdefaultdiskstore", attrs);
}
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testPdxDefaults.
@Test
public void testPdxDefaults() throws Exception {
CacheCreation creation = new CacheCreation();
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals(null, c.getPdxDiskStore());
assertEquals(null, c.getPdxSerializer());
assertEquals(false, c.getPdxPersistent());
assertEquals(false, c.getPdxReadSerialized());
assertEquals(false, c.getPdxIgnoreUnreadFields());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testMultipleCacheListener.
/**
* Tests multiple cache listeners on one region
*
* @since GemFire 5.0
*/
@Test
public void testMultipleCacheListener() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
CacheListener l1 = new MyTestCacheListener();
CacheListener l2 = new MySecondTestCacheListener();
attrs.addCacheListener(l1);
attrs.addCacheListener(l2);
cache.createRegion("root", attrs);
testXml(cache);
{
Cache c = getCache();
Region r = c.getRegion("root");
assertEquals(Arrays.asList(new CacheListener[] { l1, l2 }), Arrays.asList(r.getAttributes().getCacheListeners()));
AttributesMutator am = r.getAttributesMutator();
am.removeCacheListener(l2);
assertEquals(Arrays.asList(new CacheListener[] { l1 }), Arrays.asList(r.getAttributes().getCacheListeners()));
am.removeCacheListener(l1);
assertEquals(Arrays.asList(new CacheListener[] {}), Arrays.asList(r.getAttributes().getCacheListeners()));
am.addCacheListener(l1);
assertEquals(Arrays.asList(new CacheListener[] { l1 }), Arrays.asList(r.getAttributes().getCacheListeners()));
am.addCacheListener(l1);
assertEquals(Arrays.asList(new CacheListener[] { l1 }), Arrays.asList(r.getAttributes().getCacheListeners()));
am.addCacheListener(l2);
assertEquals(Arrays.asList(new CacheListener[] { l1, l2 }), Arrays.asList(r.getAttributes().getCacheListeners()));
am.removeCacheListener(l1);
assertEquals(Arrays.asList(new CacheListener[] { l2 }), Arrays.asList(r.getAttributes().getCacheListeners()));
am.removeCacheListener(l1);
assertEquals(Arrays.asList(new CacheListener[] { l2 }), Arrays.asList(r.getAttributes().getCacheListeners()));
am.initCacheListeners(new CacheListener[] { l1, l2 });
assertEquals(Arrays.asList(new CacheListener[] { l1, l2 }), Arrays.asList(r.getAttributes().getCacheListeners()));
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testEnableSubscriptionConflationAttribute.
/**
* Test EnableSubscriptionConflation region attribute
*
* @since GemFire 5.7
*/
@Test
public void testEnableSubscriptionConflationAttribute() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setEnableSubscriptionConflation(true);
cache.createRegion("root", attrs);
testXml(cache);
assertEquals(true, cache.getRegion("root").getAttributes().getEnableSubscriptionConflation());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testLoadPollInterval.
@Test
public void testLoadPollInterval() throws Exception {
CacheCreation cache = new CacheCreation();
CacheServer server = cache.addCacheServer();
server.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
server.setLoadPollInterval(12345);
testXml(cache);
Cache c = getCache();
server = c.getCacheServers().get(0);
assertEquals(12345, server.getLoadPollInterval());
}
Aggregations