// Cache.close();
}
}
protected void doSpringContextBootstrappingInitializationTest(final String cacheXmlFile) {
Cache gemfireCache = new CacheFactory()
.set("name", GEMFIRE_NAME)
.set("mcast-port", GEMFIRE_MCAST_PORT)
.set("log-level", GEMFIRE_LOG_LEVEL)
.set("cache-xml-file", cacheXmlFile)
//.set("locators", GEMFIRE_LOCATORS)
//.set("start-locator", GEMFIRE_LOCATORS)
//.set("jmx-manager", GEMFIRE_JMX_MANAGER)
//.set("jmx-manager-port", GEMFIRE_JMX_MANAGER_PORT)
//.set("jmx-manager-start", GEMFIRE_JMX_MANAGER_START)
.create();
assertNotNull("The GemFire Cache was not properly created and initialized!", gemfireCache);
assertFalse("The GemFire Cache is closed!", gemfireCache.isClosed());
Set<Region<?, ?>> rootRegions = gemfireCache.rootRegions();
assertNotNull(rootRegions);
assertFalse(rootRegions.isEmpty());
assertEquals(2, rootRegions.size());
assertNotNull(gemfireCache.getRegion("/TestRegion"));
assertNotNull(gemfireCache.getRegion("/Users"));
ConfigurableApplicationContext applicationContext = SpringContextBootstrappingInitializer.getApplicationContext();
assertNotNull(applicationContext);
assertTrue(applicationContext.containsBean(GemfireConstants.DEFAULT_GEMFIRE_CACHE_NAME));
assertTrue(applicationContext.containsBean("TestRegion"));
assertFalse(applicationContext.containsBean("Users")); // Region 'Users' is defined in GemFire cache.xml
assertTrue(applicationContext.containsBean("userDataSource"));
assertTrue(applicationContext.containsBean("userDao"));
assertTrue(applicationContext.containsBean("userService"));
DataSource userDataSource = applicationContext.getBean("userDataSource", DataSource.class);
TestUserDao userDao = applicationContext.getBean("userDao", TestUserDao.class);
TestUserService userService = applicationContext.getBean("userService", TestUserService.class);
assertSame(userDataSource, userDao.getDataSource());
assertSame(userDao, userService.getUserDao());
// NOTE a GemFire declared component initialized by Spring!
UserDataStoreCacheLoader usersCacheLoader = UserDataStoreCacheLoader.getInstance();
assertSame(userDataSource, usersCacheLoader.getDataSource());
Region<String, User> users = gemfireCache.getRegion("/Users");
assertNotNull(users);
assertEquals("Users", users.getName());
assertEquals("/Users", users.getFullPath());
assertTrue(users.isEmpty());