CacheFactoryBean cacheFactoryBean = new CacheFactoryBean();
cacheFactoryBean.setBeanName("gemfireCache");
cacheFactoryBean.setUseBeanFactoryLocator(false);
Cache cache = cacheFactoryBean.getObject();
assertNotNull(cache);
RegionFactoryBean regionFactory = new ReplicatedRegionFactoryBean();
regionFactory.setCache(cache);
regionFactory.setName("Outer");
regionFactory.afterPropertiesSet();
Region outer = regionFactory.getObject();
assertNotNull(outer);
assertEquals("Outer", outer.getName());
assertEquals("/Outer", outer.getFullPath());
assertSame(outer, cache.getRegion("/Outer"));
RegionFactoryBean subRegionFactory = new RegionFactoryBean();
subRegionFactory.setCache(cache);
subRegionFactory.setParent(outer);
subRegionFactory.setName("/Outer/Inner");
subRegionFactory.setRegionName("Inner");
subRegionFactory.afterPropertiesSet();
Region inner = subRegionFactory.getObject();
assertNotNull(inner);
assertSame(inner, outer.getSubregion("Inner"));
assertSame(inner, cache.getRegion("/Outer/Inner"));
}