Search in sources :

Example 6 with ClientCacheCreation

use of org.apache.geode.internal.cache.xmlcache.ClientCacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testClientLOCAL_HEAP_LRU.

@Test
public void testClientLOCAL_HEAP_LRU() throws Exception {
    ClientCacheCreation cache = new ClientCacheCreation();
    RegionCreation root = (RegionCreation) cache.createRegion("locallru", "LOCAL_HEAP_LRU");
    testXml(cache);
    GemFireCacheImpl c = (GemFireCacheImpl) getCache();
    assertEquals(true, c.isClient());
    Region r = c.getRegion("locallru");
    assertNotNull(r);
    RegionAttributes ra = r.getAttributes();
    assertEquals(DataPolicy.NORMAL, ra.getDataPolicy());
    assertEquals(Scope.LOCAL, ra.getScope());
    assertEquals(null, ra.getPoolName());
    assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes());
    assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage(), 0);
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Example 7 with ClientCacheCreation

use of org.apache.geode.internal.cache.xmlcache.ClientCacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testCACHING_PROXY_OVERFLOW.

@Test
public void testCACHING_PROXY_OVERFLOW() throws Exception {
    ClientCacheCreation cache = new ClientCacheCreation();
    RegionCreation root = (RegionCreation) cache.createRegion("cproxyoverflow", "CACHING_PROXY_OVERFLOW");
    testXml(cache);
    GemFireCacheImpl c = (GemFireCacheImpl) getCache();
    assertEquals(true, c.isClient());
    Region r = c.getRegion("cproxyoverflow");
    assertNotNull(r);
    RegionAttributes ra = r.getAttributes();
    assertEquals(DataPolicy.NORMAL, ra.getDataPolicy());
    assertEquals(Scope.LOCAL, ra.getScope());
    assertEquals("DEFAULT", ra.getPoolName());
    assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes());
    assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage(), 0);
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Example 8 with ClientCacheCreation

use of org.apache.geode.internal.cache.xmlcache.ClientCacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testClientCache.

@Test
public void testClientCache() throws Exception {
    ClientCacheCreation cache = new ClientCacheCreation();
    cache.setCopyOnRead(true);
    testXml(cache);
    GemFireCacheImpl c = (GemFireCacheImpl) getCache();
    assertEquals(true, c.getCopyOnRead());
    assertEquals(true, c.isClient());
    for (ClientRegionShortcut pra : ClientRegionShortcut.values()) {
        assertNotNull(c.getRegionAttributes(pra.name()));
    }
    assertEquals(ClientRegionShortcut.values().length, c.listRegionAttributes().size());
}
Also used : ClientRegionShortcut(org.apache.geode.cache.client.ClientRegionShortcut) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) Test(org.junit.Test)

Example 9 with ClientCacheCreation

use of org.apache.geode.internal.cache.xmlcache.ClientCacheCreation in project geode by apache.

the class CacheXml66DUnitTest method testPROXY.

@Test
public void testPROXY() throws Exception {
    ClientCacheCreation cache = new ClientCacheCreation();
    RegionCreation root = (RegionCreation) cache.createRegion("proxy", "PROXY");
    testXml(cache);
    GemFireCacheImpl c = (GemFireCacheImpl) getCache();
    assertEquals(true, c.isClient());
    Region r = c.getRegion("proxy");
    assertNotNull(r);
    RegionAttributes ra = r.getAttributes();
    assertEquals(DataPolicy.EMPTY, ra.getDataPolicy());
    assertEquals(Scope.LOCAL, ra.getScope());
    assertEquals("DEFAULT", ra.getPoolName());
}
Also used : RegionAttributes(org.apache.geode.cache.RegionAttributes) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) LocalRegion(org.apache.geode.internal.cache.LocalRegion) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) Region(org.apache.geode.cache.Region) DistributedRegion(org.apache.geode.internal.cache.DistributedRegion) RegionCreation(org.apache.geode.internal.cache.xmlcache.RegionCreation) Test(org.junit.Test)

Example 10 with ClientCacheCreation

use of org.apache.geode.internal.cache.xmlcache.ClientCacheCreation in project geode by apache.

the class CacheXmlTestCase method testXml.

protected void testXml(CacheCreation creation, boolean checkSame) throws IOException {
    File root = this.temporaryFolder.getRoot();
    File dir = new File(root, "XML_" + getGemFireVersion());
    dir.mkdirs();
    File file = new File(dir, getUniqueName() + ".xml");
    final boolean useSchema = getUseSchema();
    final String version = getGemFireVersion();
    PrintWriter pw = new PrintWriter(new FileWriter(file), true);
    CacheXmlGenerator.generate(creation, pw, useSchema, version);
    pw.close();
    setXmlFile(file);
    boolean client = creation instanceof ClientCacheCreation;
    Cache cache = getCache(client);
    try {
        if (checkSame && !creation.sameAs(cache)) {
            StringWriter sw = new StringWriter();
            CacheXmlGenerator.generate(creation, new PrintWriter(sw, true), useSchema, version);
            CacheXmlGenerator.generate(cache, new PrintWriter(sw, true), useSchema, version);
            fail(sw.toString());
        }
    } catch (RuntimeException re) {
        StringWriter sw = new StringWriter();
        CacheXmlGenerator.generate(creation, new PrintWriter(sw, true), useSchema, version);
        CacheXmlGenerator.generate(cache, new PrintWriter(sw, true), useSchema, version);
        fail(sw.toString(), re);
    }
}
Also used : StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) ClientCacheCreation(org.apache.geode.internal.cache.xmlcache.ClientCacheCreation) File(java.io.File) PrintWriter(java.io.PrintWriter) Cache(org.apache.geode.cache.Cache)

Aggregations

ClientCacheCreation (org.apache.geode.internal.cache.xmlcache.ClientCacheCreation)13 Test (org.junit.Test)12 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)10 Region (org.apache.geode.cache.Region)9 RegionAttributes (org.apache.geode.cache.RegionAttributes)9 DistributedRegion (org.apache.geode.internal.cache.DistributedRegion)9 LocalRegion (org.apache.geode.internal.cache.LocalRegion)9 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)9 RegionCreation (org.apache.geode.internal.cache.xmlcache.RegionCreation)9 Cache (org.apache.geode.cache.Cache)2 CacheTransactionManagerCreation (org.apache.geode.internal.cache.xmlcache.CacheTransactionManagerCreation)2 File (java.io.File)1 FileWriter (java.io.FileWriter)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)1 ClientCache (org.apache.geode.cache.client.ClientCache)1 ClientRegionShortcut (org.apache.geode.cache.client.ClientRegionShortcut)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1