public void testRegionFactoryProperties() throws CacheException, IOException { Region r1 = null; try { final Properties props1 = new Properties(); props1.put("mcast-ttl", "64"); RegionFactory factory = new RegionFactory(props1); r1 = factory.create(this.r1Name); assertBasicRegionFunctionality(r1, r1Name); assertEquals(props1.get("mcast-ttl"), r1.getCache().getDistributedSystem().getProperties().get("mcast-ttl")); } finally { cleanUpRegion(r1); } }
public void testPARTITION_REDUNDANT() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(PARTITION_REDUNDANT); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(1, ra.getPartitionAttributes().getRedundantCopies()); } finally { cleanUpRegion(r1); } } public void testPARTITION_PERSISTENT() throws CacheException, IOException
assertTrue(af.length != 0); for (int i=0; i<af.length; i++) { am = af[i]; fail("RegionFactory does not conform to AttributesFactory, its should proxy these methods " + methodsToImplement);
public void testREPLICATE_PROXY() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(REPLICATE_PROXY); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.EMPTY, ra.getDataPolicy()); assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope()); } finally { cleanUpRegion(r1); } }
+ "<cache>\n" + " <region-attributes id=\"" + getName() + "\" statistics-enabled=\"true\" scope=\"distributed-ack\">\n" + " <key-constraint>" f.close(); RegionFactory factory = new RegionFactory(getName()); r1 = factory.create(this.r1Name); assertBasicRegionFunctionality(r1, r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(ra.getStatisticsEnabled(), true); assertEquals(ra.getScope().isDistributedAck(), true); assertEquals(ra.getValueConstraint(), Integer.class); assertEquals(ra.getKeyConstraint(), String.class); assertEquals(ra.getEntryIdleTimeout().getTimeout(), 60); cleanUpRegion(r1);
public void testRegionFactoryRegionAttributes() throws CacheException { Region r1 = null, r2 = null, r3 = null; try { Properties p = new Properties(); p.put("mcast-port", "0"); r1 = new RegionFactory(p).setScope(Scope.LOCAL) .setConcurrencyLevel(1).setLoadFactor(0.8F).setKeyConstraint( String.class).setStatisticsEnabled(true).create(r1Name); assertBasicRegionFunctionality(r1, r1Name); final RegionFactory factory = new RegionFactory(p, r1.getAttributes()); r2 = factory.create(r2Name); assertBasicRegionFunctionality(r2, r2Name); assertEquals(r1.getAttributes(), r2.getAttributes()); r3 = factory.create(r3Name); try { assertEquals(r2.getAttributes(), r3.getAttributes()); fail("Expected r2 attributes to be different from r3"); } catch (AssertionFailedError expected) { } } finally { cleanUpRegion(r1); cleanUpRegion(r2); cleanUpRegion(r3); } }
RegionFactory factory = new RegionFactory(); r1 = factory.create(r1Name); assertBasicRegionFunctionality(r1, r1Name); fail("Expected RegionExistsException"); assertBasicRegionFunctionality(r1sr1, r1sr1Name); try { factory.createSubregion(r1, r1sr1Name); fail("Expected RegionExistsException"); assertBasicRegionFunctionality(r2, r2Name); r2.destroyRegion(); fail("Expected a RegionDestroyedException"); } catch (RegionDestroyedException expected) { assertBasicRegionFunctionality(r1, r1Name); assertBasicRegionFunctionality(r1, r1Name); assertBasicRegionFunctionality(r1, r1Name); cleanUpRegion(r1sr1); cleanUpRegion(r1); cleanUpRegion(r2); try { tearDown(); } catch (Exception tearDownBummer) {
public void testLOCAL_OVERFLOW() throws CacheException, IOException { Cache c = new CacheFactory().create(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL_OVERFLOW); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.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()); } finally { cleanUpRegion(r1); } } public void testLOCAL_PERSISTENT_OVERFLOW() throws CacheException, IOException
public static void assertEquals(RegionAttributes ra1, RegionAttributes ra2) { assertEquals(ra1.getScope(), ra2.getScope()); assertEquals(ra1.getKeyConstraint(), ra2.getKeyConstraint()); assertEquals(ra1.getValueConstraint(), ra2.getValueConstraint()); assertEquals(ra1.getCacheListener(), ra2.getCacheListener()); assertEquals(ra1.getCacheWriter(), ra2.getCacheWriter()); assertEquals(ra1.getCacheLoader(), ra2.getCacheLoader()); assertEquals(ra1.getStatisticsEnabled(), ra2.getStatisticsEnabled()); assertEquals(ra1.getConcurrencyLevel(), ra2.getConcurrencyLevel()); assertEquals(ra1.getInitialCapacity(), ra2.getInitialCapacity()); assertTrue(ra1.getLoadFactor() == ra2.getLoadFactor()); assertEquals(ra1.getEarlyAck(), ra2.getEarlyAck()); assertEquals(ra1.isDiskSynchronous(), ra2.isDiskSynchronous()); assertEquals(ra1.getDiskStoreName(), ra2.getDiskStoreName()); }
public void assertBasicRegionFunctionality(Region r, String name) { assertEquals(r.getName(), name); r.put(key, val); assertEquals(r.getEntry(key).getValue(), val); }
public void testREPLICATE_PERSISTENT() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(REPLICATE_PERSISTENT); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope()); } finally { cleanUpRegion(r1); } } public void testREPLICATE_OVERFLOW() throws CacheException, IOException
final Properties props2 = new Properties(); props2.put("mcast-ttl", "64"); final String xmlFileName = getName() + "-cache.xml"; props2.put("cache-xml-file", xmlFileName); xmlFile = new File(xmlFileName); xmlFile.createNewFile(); FileWriter f = new FileWriter(xmlFile); final String attrsId = getName() + "-attrsId"; f.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n" + "<!DOCTYPE cache PUBLIC\n \"-//GemStone Systems, Inc.//GemFire Declarative Caching 6.5//EN\"\n" assertBasicRegionFunctionality(r1, r1Name); assertEquals(props2.get("mcast-ttl"), r1.getCache().getDistributedSystem().getProperties().get("mcast-ttl")); assertEquals(props2.get("cache-xml-file"), r1.getCache().getDistributedSystem().getProperties().get("cache-xml-file")); RegionAttributes ra = r1.getAttributes(); assertEquals(ra.getStatisticsEnabled(), true); assertEquals(ra.getScope().isDistributedAck(), true); assertEquals(ra.getValueConstraint(), Integer.class); assertEquals(ra.getKeyConstraint(), String.class); assertEquals(ra.getEntryIdleTimeout().getTimeout(), 60); } finally { if (xmlFile != null) { xmlFile.delete(); cleanUpRegion(r1);
public void testLOCAL_HEAP_LRU() throws CacheException, IOException { Cache c = new CacheFactory().create(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL_HEAP_LRU); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } finally { cleanUpRegion(r1); } } public void testLOCAL_OVERFLOW() throws CacheException, IOException
public void testLOCAL() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); } finally { cleanUpRegion(r1); } } public void testLOCAL_PERSISTENT() throws CacheException, IOException
public void testPARTITION() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(PARTITION); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(0, ra.getPartitionAttributes().getRedundantCopies()); } finally { cleanUpRegion(r1); } } public void testPARTITION_REDUNDANT() throws CacheException, IOException
public void testLOCAL_PERSISTENT_OVERFLOW() throws CacheException, IOException { Cache c = new CacheFactory().create(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL_PERSISTENT_OVERFLOW); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, 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()); } finally { cleanUpRegion(r1); } } public void testPARTITION_PROXY() throws CacheException, IOException
public void testREPLICATE() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(REPLICATE); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.REPLICATE, ra.getDataPolicy()); assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope()); } finally { cleanUpRegion(r1); } } public void testREPLICATE_PERSISTENT() throws CacheException, IOException
public void testPARTITION_PERSISTENT() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(PARTITION_PERSISTENT); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PERSISTENT_PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(0, ra.getPartitionAttributes().getRedundantCopies()); } finally { cleanUpRegion(r1); } } public void testPARTITION_REDUNDANT_PERSISTENT() throws CacheException, IOException
public void testLOCAL_PERSISTENT() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL_PERSISTENT); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); } finally { cleanUpRegion(r1); } } public void testLOCAL_HEAP_LRU() throws CacheException, IOException
public void testPARTITION_REDUNDANT_PERSISTENT() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(PARTITION_REDUNDANT_PERSISTENT); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.PERSISTENT_PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(1, ra.getPartitionAttributes().getRedundantCopies()); } finally { cleanUpRegion(r1); } } public void testPARTITION_OVERFLOW() throws CacheException, IOException