Search in sources :

Example 1 with StatisticsDisabledException

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...
    }
}
Also used : AttributesFactory(org.apache.geode.cache.AttributesFactory) Region(org.apache.geode.cache.Region) StatisticsDisabledException(org.apache.geode.cache.StatisticsDisabledException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

AttributesFactory (org.apache.geode.cache.AttributesFactory)1 Region (org.apache.geode.cache.Region)1 StatisticsDisabledException (org.apache.geode.cache.StatisticsDisabledException)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 Test (org.junit.Test)1