@Test
  public void testCacheLoader() throws CacheException {
    final String name = getUniqueName();
    final Object key = getUniqueName();
    final Object value = 42;
    final Object arg = "ARG";
    final String exception = "EXCEPTION";

    TestCacheLoader loader = new TestCacheLoader() {
      @Override
      public Object load2(LoaderHelper helper) throws CacheLoaderException {

        assertEquals(key, helper.getKey());
        assertEquals(name, helper.getRegion().getName());

        try {
          RegionAttributes attrs = helper.getRegion().getAttributes();
          if (attrs.getScope().isDistributed()) {
            assertNull(helper.netSearch(false));
            assertNull(helper.netSearch(true));
          }

        } catch (TimeoutException ex) {
          Assert.fail("Why did I time out?", ex);
        }

        Object argument = helper.getArgument();
        if (argument != null) {
          if (argument.equals(exception)) {
            String s = "Test Exception";
            throw new CacheLoaderException(s);

          } else {
            assertEquals(arg, argument);
          }
        }

        return value;
      }
    };

    AttributesFactory factory = new AttributesFactory(getRegionAttributes());
    factory.setCacheLoader(loader);
    Region region = createRegion(name, factory.create());
    loader.wasInvoked();

    Region.Entry entry = region.getEntry(key);
    assertNull(entry);
    region.create(key, null);

    entry = region.getEntry(key);
    assertNotNull(entry);
    assertNull(entry.getValue());

    assertEquals(value, region.get(key));
    assertTrue(loader.wasInvoked());
    assertEquals(value, region.getEntry(key).getValue());
  }
An abstract class whose test methods test the functionality of {@link CacheLoader}s that are
invoked locally.

@see MultiVMRegionTestCase#testRemoteCacheLoader

@since GemFire 3.0
geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheLoaderTestCase.java