use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testPartitionedRegionAttributesForCoLocation.
@Test
public void testPartitionedRegionAttributesForCoLocation() throws Exception {
closeCache();
CacheCreation cache = new CacheCreation();
RegionAttributesCreation custAttrs = new RegionAttributesCreation(cache);
RegionAttributesCreation orderAttrs = new RegionAttributesCreation(cache);
PartitionAttributesFactory custPaf = new PartitionAttributesFactory();
PartitionAttributesFactory orderPaf = new PartitionAttributesFactory();
custPaf.setRedundantCopies(1);
custPaf.setTotalMaxMemory(500);
custPaf.setLocalMaxMemory(100);
custAttrs.setPartitionAttributes(custPaf.create());
cache.createRegion("Customer", custAttrs);
orderPaf.setRedundantCopies(1);
orderPaf.setTotalMaxMemory(500);
orderPaf.setLocalMaxMemory(100);
orderPaf.setColocatedWith("Customer");
orderAttrs.setPartitionAttributes(orderPaf.create());
cache.createRegion("Order", orderAttrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region cust = c.getRegion(Region.SEPARATOR + "Customer");
assertNotNull(cust);
Region order = c.getRegion(Region.SEPARATOR + "Order");
assertNotNull(order);
String coLocatedRegion = order.getAttributes().getPartitionAttributes().getColocatedWith();
assertEquals("Customer", coLocatedRegion);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testServer.
/**
* Tests the cache server attribute
*
* @since GemFire 4.0
*/
@Test
public void testServer() throws Exception {
CacheCreation cache = new CacheCreation();
cache.setIsServer(true);
assertTrue(cache.isServer());
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml70DUnitTest method testAsyncEventQueue.
@Test
public void testAsyncEventQueue() throws Exception {
getSystem();
CacheCreation cache = new CacheCreation();
String id = "WBCLChannel";
AsyncEventQueueFactory factory = cache.createAsyncEventQueueFactory();
factory.setBatchSize(100);
factory.setBatchTimeInterval(500);
factory.setBatchConflationEnabled(true);
factory.setMaximumQueueMemory(200);
factory.setDiskSynchronous(true);
factory.setParallel(false);
factory.setDispatcherThreads(19);
AsyncEventListener eventListener = new MyAsyncEventListener();
AsyncEventQueue asyncEventQueue = factory.create(id, eventListener);
RegionAttributesCreation attrs = new RegionAttributesCreation();
attrs.addAsyncEventQueueId(asyncEventQueue.getId());
cache.createRegion("UserRegion", attrs);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Set<AsyncEventQueue> asyncEventQueuesOnCache = c.getAsyncEventQueues();
assertTrue("Size of asyncEventQueues should be greater than 0", asyncEventQueuesOnCache.size() > 0);
for (AsyncEventQueue asyncEventQueueOnCache : asyncEventQueuesOnCache) {
validateAsyncEventQueue(asyncEventQueue, asyncEventQueueOnCache);
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testTransactionListener.
/**
* Tests a cache listener with no parameters
*
* @since GemFire 4.0
*/
@Test
public void testTransactionListener() throws Exception {
CacheCreation cache = new CacheCreation();
CacheTransactionManagerCreation txMgrCreation = new CacheTransactionManagerCreation();
txMgrCreation.setListener(new MyTestTransactionListener());
cache.addCacheTransactionManagerCreation(txMgrCreation);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testCacheWriter.
/**
* Tests a cache writer with no parameters
*/
@Test
public void testCacheWriter() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
CacheWriter writer = new MyTestCacheWriter();
attrs.setCacheWriter(writer);
cache.createRegion("root", attrs);
testXml(cache);
}
Aggregations