use of org.apache.geode.cache.StatisticsDisabledException in project geode by apache.
the class CacheStatisticsDUnitTest method testDisabledStatistics.
/**
* Tests that an attempt to get statistics when they are disabled results in a
* {@link StatisticsDisabledException}.
*/
@Test
public void testDisabledStatistics() throws CacheException {
String name = this.getUniqueName();
Object key = "KEY";
Object value = "VALUE";
AttributesFactory factory = new AttributesFactory();
factory.setStatisticsEnabled(false);
Region region = createRegion(name, factory.create());
try {
region.getStatistics();
fail("Should have thrown a StatisticsDisabledException");
} catch (StatisticsDisabledException ex) {
// pass...
}
region.put(key, value);
Region.Entry entry = region.getEntry(key);
try {
entry.getStatistics();
} catch (StatisticsDisabledException ex) {
// pass...
}
}
Aggregations