Refactored and fixed failing test cases after the integration of SGF-207, SGF-254, SGF-307, SGF-309, SGF-310, SGF-311 and SGF-312.

This commit is contained in:
John Blum
2014-08-29 13:46:09 -07:00
parent b68074c85c
commit b251a9071a
5 changed files with 37 additions and 21 deletions

View File

@@ -17,6 +17,7 @@
package org.springframework.data.gemfire.config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
@@ -43,6 +44,7 @@ import org.springframework.util.FileSystemUtils;
import com.gemstone.gemfire.cache.Cache;
import com.gemstone.gemfire.cache.CustomExpiry;
import com.gemstone.gemfire.cache.DataPolicy;
import com.gemstone.gemfire.cache.DiskStore;
import com.gemstone.gemfire.cache.DiskStoreFactory;
import com.gemstone.gemfire.cache.EvictionAction;
@@ -113,20 +115,31 @@ public class DiskStoreAndEvictionRegionParsingTest {
@Test
@SuppressWarnings("rawtypes")
public void testReplicaDataOptions() throws Exception {
public void testReplicatedDataRegionAttributes() throws Exception {
assertTrue(context.containsBean("replicated-data"));
RegionFactoryBean fb = context.getBean("&replicated-data", RegionFactoryBean.class);
assertTrue(fb instanceof ReplicatedRegionFactoryBean);
assertEquals(Scope.DISTRIBUTED_ACK, TestUtils.readField("scope", fb));
@SuppressWarnings("unused")
Region region = context.getBean("replicated-data", Region.class);
// eviction tests
RegionAttributes attrs = TestUtils.readField("attributes", fb);
EvictionAttributes evicAttr = attrs.getEvictionAttributes();
assertEquals(EvictionAction.OVERFLOW_TO_DISK, evicAttr.getAction());
assertEquals(EvictionAlgorithm.LRU_ENTRY, evicAttr.getAlgorithm());
assertEquals(50, evicAttr.getMaximum());
assertNull(evicAttr.getObjectSizer());
RegionFactoryBean replicatedDataRegionFactoryBean = context.getBean("&replicated-data", RegionFactoryBean.class);
assertTrue(replicatedDataRegionFactoryBean instanceof ReplicatedRegionFactoryBean);
assertEquals(DataPolicy.REPLICATE, replicatedDataRegionFactoryBean.getDataPolicy());
assertFalse(replicatedDataRegionFactoryBean.getDataPolicy().withPersistence());
assertEquals("diskStore1", TestUtils.readField("diskStoreName", replicatedDataRegionFactoryBean));
assertNull(TestUtils.readField("scope", replicatedDataRegionFactoryBean));
Region replicatedDataRegion = context.getBean("replicated-data", Region.class);
RegionAttributes replicatedDataRegionAttributes = TestUtils.readField("attributes", replicatedDataRegionFactoryBean);
assertNotNull(replicatedDataRegionAttributes);
assertEquals(Scope.DISTRIBUTED_NO_ACK, replicatedDataRegionAttributes.getScope());
EvictionAttributes replicatedDataEvictionAttributes = replicatedDataRegionAttributes.getEvictionAttributes();
assertNotNull(replicatedDataEvictionAttributes);
assertEquals(EvictionAction.OVERFLOW_TO_DISK, replicatedDataEvictionAttributes.getAction());
assertEquals(EvictionAlgorithm.LRU_ENTRY, replicatedDataEvictionAttributes.getAlgorithm());
assertEquals(50, replicatedDataEvictionAttributes.getMaximum());
assertNull(replicatedDataEvictionAttributes.getObjectSizer());
}
@Test

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
@@ -71,11 +72,13 @@ public class ReplicatedRegionNamespaceTest {
assertEquals("simple", TestUtils.readField("beanName", simpleRegionFactoryBean));
assertEquals(false, TestUtils.readField("close", simpleRegionFactoryBean));
assertNull(TestUtils.readField("scope", simpleRegionFactoryBean));
RegionAttributes simpleRegionAttributes = TestUtils.readField("attributes", simpleRegionFactoryBean);
assertNotNull(simpleRegionAttributes);
assertFalse(simpleRegionAttributes.getConcurrencyChecksEnabled());
assertEquals(Scope.DISTRIBUTED_NO_ACK, simpleRegionAttributes.getScope());
}
@Test

View File

@@ -48,13 +48,12 @@ import com.gemstone.gemfire.cache.Region;
*/
@ContextConfiguration(locations = "subregion-ns.xml", initializers = GemfireTestApplicationContextInitializer.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SuppressWarnings("deprecation")
@SuppressWarnings({ "deprecation", "rawtypes" })
public class SubRegionNamespaceTest {
@Autowired
private ApplicationContext context;
@SuppressWarnings("rawtypes")
@Test
public void testNestedRegionsCreated() {
Cache cache = context.getBean(Cache.class);
@@ -64,7 +63,6 @@ public class SubRegionNamespaceTest {
assertNotNull(cache.getRegion("/parent/child/grandchild"));
}
@SuppressWarnings("rawtypes")
@Test
public void testNestedReplicatedRegions() {
Region parent = context.getBean("parent", Region.class);
@@ -72,15 +70,17 @@ public class SubRegionNamespaceTest {
Region grandchild = context.getBean("/parent/child/grandchild", Region.class);
assertNotNull(child);
assertEquals("child", child.getName());
assertEquals("/parent/child", child.getFullPath());
assertSame(child, parent.getSubregion("child"));
assertNotNull(grandchild);
assertEquals("grandchild", grandchild.getName());
assertEquals("/parent/child/grandchild", grandchild.getFullPath());
assertSame(grandchild, child.getSubregion("grandchild"));
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
@SuppressWarnings("unchecked")
public void testMixedNestedRegions() {
Region parent = context.getBean("replicatedParent", Region.class);
Region child = context.getBean("/replicatedParent/replicatedChild", Region.class);
@@ -94,7 +94,6 @@ public class SubRegionNamespaceTest {
assertSame(grandchild, child.getSubregion("partitionedGrandchild"));
}
@SuppressWarnings("rawtypes")
@Test
public void testNestedRegionsWithSiblings() {
Region parent = context.getBean("parentWithSiblings", Region.class);
@@ -108,8 +107,8 @@ public class SubRegionNamespaceTest {
assertEquals("/parentWithSiblings/child1/grandChild11", grandchild1.getFullPath());
}
@SuppressWarnings({ "rawtypes", "unused" })
@Test
@SuppressWarnings("unused" )
public void testComplexNestedRegions() throws Exception {
Region parent = context.getBean("complexNested", Region.class);
Region child1 = context.getBean("/complexNested/child1", Region.class);

View File

@@ -110,6 +110,7 @@ public class MockRegionFactory<K,V> {
Region subRegion = mockRegion(subRegionName);
cache.allRegions().put(subRegionName, subRegion);
cache.allRegions().put(name, subRegion);
return subRegion;
}
@@ -468,7 +469,7 @@ public class MockRegionFactory<K,V> {
public Region answer(InvocationOnMock invocation) throws Throwable {
Region parent = (Region) invocation.getMock();
String parentRegionName = parent.getName();
String parentRegionName = parent.getFullPath();
String subRegionName = (String) invocation.getArguments()[0];
String subRegionPath = (parentRegionName.startsWith("/") ? parentRegionName+"/"+subRegionName
: "/"+parentRegionName+"/"+subRegionName);