@Test
  public void testCacheWriterExceptionAborts() throws CacheException {
    final String name = getUniqueName();
    final String exception = "EXCEPTION";

    TestCacheWriter writer = new TestCacheWriter() {
      private void handleEvent(Object argument) throws CacheWriterException {

        if (exception.equals(argument)) {
          String s = "Test Exception";
          throw new CacheWriterException(s);
        }
      }

      @Override
      public void beforeCreate2(EntryEvent event) throws CacheWriterException {

        handleEvent(event.getCallbackArgument());
      }

      @Override
      public void beforeUpdate2(EntryEvent event) throws CacheWriterException {

        handleEvent(event.getCallbackArgument());
      }

      @Override
      public void beforeDestroy2(EntryEvent event) throws CacheWriterException {

        handleEvent(event.getCallbackArgument());
      }

      @Override
      public void beforeRegionDestroy2(RegionEvent event) throws CacheWriterException {

        handleEvent(event.getCallbackArgument());
      }
    };

    AttributesFactory factory = new AttributesFactory(getRegionAttributes());
    factory.setCacheWriter(writer);
    RegionAttributes attrs = factory.create();
    Region region;

    region = createRegion(name, attrs);
    Object value = 42;

    String p1 = "Test Exception";
    getCache().getLogger().info("<ExpectedException action=add>" + p1 + "</ExpectedException>");
    try {
      region.put(name, value, exception);
      fail("Should have thrown a CacheWriterException");

    } catch (CacheWriterException ex) {
      assertNull(region.getEntry(name));
    } finally {
      getCache().getLogger()
          .info("<ExpectedException action=remove>" + p1 + "</ExpectedException>");
    }

    region.put(name, value);

    try {
      region.put(name, "NEVER SEEN", exception);
      fail("Should have thrown a CacheWriterException");

    } catch (CacheWriterException ex) {
      Region.Entry entry = region.getEntry(name);
      assertNotNull(entry);
      assertEquals(value, entry.getValue());
    }

    try {
      region.destroy(name, exception);
      fail("Should have thrown a CacheWriterException");

    } catch (CacheWriterException ex) {
      Region.Entry entry = region.getEntry(name);
      assertNotNull(entry);
      assertEquals(value, entry.getValue());
    }

    try {
      region.destroyRegion(exception);

    } catch (CacheWriterException ex) {
      assertTrue(!region.isDestroyed());
      assertNotNull(region.getParentRegion().getSubregion(name));
    }
  }
Tests that a {@link CacheWriter} throwing a {@link CacheWriterException} aborts the operation.
geode-core/src/distributedTest/java/org/apache/geode/cache30/CacheWriterTestCase.java