@Test
  public void testPoolAndWriter() throws Exception {
    final String regionName = getName();
    final Host host = Host.getHost(0);
    VM server = host.getVM(0);
    VM client = host.getVM(1);

    final int serverPort = getRandomAvailableTCPPort();
    server.invoke(new SerializableCallable() {
      @Override
      public Object call() throws IOException {
        Cache cache = getCache();
        AttributesFactory af = new AttributesFactory();
        RegionAttributes attrs = af.create();
        cache.createRegion(regionName, attrs);

        startBridgeServer(serverPort, true);
        return null;
      }
    });

    client.invoke(new SerializableCallable() {
      @Override
      public Object call() {
        Cache cache = getCache();
        PoolFactory factory = PoolManager.createFactory();
        factory.addServer(NetworkUtils.getServerHostName(host), serverPort);
        factory.create("pool1");

        AttributesFactory af = new AttributesFactory();
        af.setDataPolicy(DataPolicy.DEFAULT);
        af.setScope(Scope.LOCAL);
        af.setPoolName("pool1");
        af.setCacheWriter(new MyCacheWriter());
        RegionAttributes attrs = af.create();
        cache.createRegion(regionName, attrs);

        return null;
      }
    });

    client.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        MyCacheWriter writer = (MyCacheWriter) region.getAttributes().getCacheWriter();
        region.put("a", "a");
        region.put("b", "b");
        region.put("c", "c");
        region.destroy("c");
        writer.throwException = true;
        try {
          region.put("a", "new-a");
          fail("Should have gotten a cache writer exception");
        } catch (CacheWriterException e) {
          assertEquals("beforeUpdate", e.getMessage());
        }
        try {
          region.destroy("b");
          fail("Should have gotten a cache writer exception");
        } catch (CacheWriterException e) {
          assertEquals("beforeDestroy", e.getMessage());
        }
        try {
          region.put("d", "d");
          fail("Should have gotten a cache writer exception");
        } catch (CacheWriterException e) {
          assertEquals("beforeCreate", e.getMessage());
        }
        try {
          region.clear();
          fail("Should have gotten a cache writer exception");
        } catch (CacheWriterException e) {
          assertEquals("beforeRegionClear", e.getMessage());
        }
        try {
          region.destroyRegion();
          fail("Should have gotten a cache writer exception");
        } catch (CacheWriterException e) {
          assertEquals("beforeRegionDestroy", e.getMessage());
        }
      }
    });

    server.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        assertEquals("a", region.get("a"));
        assertEquals("b", region.get("b"));
        assertEquals(null, region.get("c"));
        assertEquals(null, region.get("d"));
      }
    });
  }
Test the we can have both a connection pool and a cache writer.

The expected order of operations for put is: local writer put on server
geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolAndLoaderDUnitTest.java