use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testDefaultCacheServerBindAddress.
@Test
public void testDefaultCacheServerBindAddress() throws Exception {
CacheCreation cache = new CacheCreation();
CacheServer bs = cache.addCacheServer();
bs.setPort(AvailablePortHelper.getRandomAvailableTCPPort());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
CacheServer server = (CacheServer) cache.getCacheServers().iterator().next();
assertNotNull(server);
assertEquals(CacheServer.DEFAULT_BIND_ADDRESS, server.getBindAddress());
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testPdxAttributes.
@Test
public void testPdxAttributes() throws Exception {
CacheCreation creation = new CacheCreation();
creation.setPdxPersistent(true);
creation.setPdxReadSerialized(true);
creation.setPdxIgnoreUnreadFields(true);
creation.setPdxDiskStore("my_disk_store");
TestPdxSerializer serializer = new TestPdxSerializer();
Properties props = new Properties();
props.setProperty("hello", "there");
serializer.init(props);
creation.setPdxSerializer(serializer);
testXml(creation);
Cache c = getCache();
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
// test that we can override the cache.xml attributes
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxDiskStore("new disk store");
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("new disk store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
}
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxPersistent(false);
cf.setPdxIgnoreUnreadFields(false);
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(false, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(false, c.getPdxIgnoreUnreadFields());
}
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxSerializer(null);
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(null, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(true, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
}
{
closeCache();
CacheFactory cf = new CacheFactory();
cf.setPdxReadSerialized(false);
c = getCache(cf);
assertTrue(c instanceof GemFireCacheImpl);
c.loadCacheXml(generate(creation));
assertEquals("my_disk_store", c.getPdxDiskStore());
assertEquals(serializer, c.getPdxSerializer());
assertEquals(true, c.getPdxPersistent());
assertEquals(false, c.getPdxReadSerialized());
assertEquals(true, c.getPdxIgnoreUnreadFields());
}
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testPartitionedRegionAttributesForCustomPartitioning.
/**
* Tests that a region created with a named attributes set programmatically for partition-resolver
* has the correct attributes.
*/
@Test
public void testPartitionedRegionAttributesForCustomPartitioning() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
CacheXMLPartitionResolver partitionResolver = new CacheXMLPartitionResolver();
Properties params = new Properties();
params.setProperty("initial-index-value", "1000");
params.setProperty("secondary-index-value", "5000");
partitionResolver.init(params);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setTotalMaxMemory(500);
paf.setLocalMaxMemory(100);
paf.setPartitionResolver(partitionResolver);
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(r.getAttributes().getPartitionAttributes().getPartitionResolver(), partitionResolver);
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);
assertNotNull(pa.getPartitionResolver().getClass());
assertEquals(pa.getPartitionResolver(), partitionResolver);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testLOCAL_OVERFLOW.
@Test
public void testLOCAL_OVERFLOW() throws Exception {
CacheCreation cache = new CacheCreation();
RegionCreation root = (RegionCreation) cache.createRegion("localoverflow", "LOCAL_OVERFLOW");
testXml(cache);
GemFireCacheImpl c = (GemFireCacheImpl) getCache();
Region r = c.getRegion("localoverflow");
assertNotNull(r);
RegionAttributes ra = r.getAttributes();
assertEquals(DataPolicy.NORMAL, ra.getDataPolicy());
assertEquals(Scope.LOCAL, ra.getScope());
assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage(), 0);
}
use of org.apache.geode.internal.cache.xmlcache.CacheCreation in project geode by apache.
the class CacheXml66DUnitTest method testConstrainedValues.
/**
* Tests the value constraints region attribute that was added in GemFire 4.0.
*
* @since GemFire 4.1
*/
@Test
public void testConstrainedValues() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setValueConstraint(String.class);
cache.createRegion("root", attrs);
testXml(cache);
}
Aggregations