use of org.apache.geode.internal.cache.control.ResourceListener in project geode by apache.
the class ResourceManagerDUnitTest method testResourceManagerBasics.
/**
* Creates a cache in the controller and exercises all methods on the ResourceManager without
* having any partitioned regions defined.
*/
@Test
public void testResourceManagerBasics() {
Cache cache = getCache();
// verify that getResourceManager works
ResourceManager manager = cache.getResourceManager();
assertNotNull(manager);
// verify that getPartitionedRegionDetails returns empty set
Set<PartitionRegionInfo> detailsSet = PartitionRegionHelper.getPartitionRegionInfo(cache);
assertNotNull(detailsSet);
assertEquals(Collections.emptySet(), detailsSet);
ResourceListener listener = new ResourceListener() {
public void onEvent(ResourceEvent event) {
}
};
InternalResourceManager internalManager = (InternalResourceManager) manager;
// verify that addResourceListener works
internalManager.addResourceListener(listener);
Set<ResourceListener> listeners = internalManager.getResourceListeners(ResourceType.HEAP_MEMORY);
assertNotNull(listeners);
assertEquals(1 + SYSTEM_LISTENERS, listeners.size());
assertTrue(listeners.contains(listener));
// verify that repeat adds result in only one entry of the listener
internalManager.addResourceListener(ResourceType.HEAP_MEMORY, listener);
listeners = internalManager.getResourceListeners(ResourceType.HEAP_MEMORY);
assertEquals(1 + SYSTEM_LISTENERS, listeners.size());
// verify that removeResourceListener works
internalManager.removeResourceListener(listener);
listeners = internalManager.getResourceListeners(ResourceType.HEAP_MEMORY);
assertEquals(listeners.size(), SYSTEM_LISTENERS);
}
Aggregations