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

    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;
      }
    });

    SerializableCallable createClient1 = new SerializableCallable() {
      @Override
      public Object call() {
        // Make sure we get a distributed system that has the locator
        useLocator = true;
        Cache cache = getCache();
        useLocator = false;
        PoolFactory factory = PoolManager.createFactory();
        factory.addServer(NetworkUtils.getServerHostName(host), serverPort);
        factory.create("pool1");
        AttributesFactory af = new AttributesFactory();
        af.setDataPolicy(DataPolicy.NORMAL);
        af.setScope(Scope.DISTRIBUTED_ACK);
        af.setPoolName("pool1");
        af.setCacheLoader(new MyCacheLoader("loaded1"));
        RegionAttributes attrs = af.create();
        cache.createRegion(regionName, attrs);
        return null;
      }
    };
    client1.invoke(createClient1);

    SerializableCallable createClient2 = new SerializableCallable() {
      @Override
      public Object call() {
        // Make sure we get a distributed system that has the locator
        useLocator = true;
        Cache cache = getCache();
        useLocator = false;
        PoolFactory factory = PoolManager.createFactory();
        factory.addServer(NetworkUtils.getServerHostName(host), serverPort);
        factory.create("pool1");
        AttributesFactory af = new AttributesFactory();
        af.setDataPolicy(DataPolicy.NORMAL);
        af.setScope(Scope.DISTRIBUTED_ACK);
        af.setCacheLoader(new MyCacheLoader("loaded2"));
        af.setPoolName("pool1");
        RegionAttributes attrs = af.create();
        cache.createRegion(regionName, attrs);
        return null;
      }
    };
    client2.invoke(createClient2);

    // We need to test what happens when
    // we do a load in client1 in each of these cases:
    // Case On Server On Client 1 On Client 2 Expected
    // a X server
    // b X X client1
    // c X X X client1
    // d X X client2
    // e X client1
    // f X X client1
    // g X client2 (loader does a netSearch)
    // h client1 loader

    // Setup scenarios
    client1.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        region.put("b", "client1-b");
        region.put("c", "client1-c");
        region.put("e", "client1-e");
        region.put("f", "client1-f");
      }
    });

    client2.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        assertEquals("client1-c", region.get("c"));
        region.put("d", "client2-d");
        assertEquals("client1-f", region.get("f"));
        region.put("g", "client2-g");
      }
    });

    server.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        region.put("a", "server-a");
        region.localDestroy("e");
        region.localDestroy("f");
        region.localDestroy("g");
      }
    });

    // Test the scenarios
    client1.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        assertEquals("server-a", region.get("a"));
        assertEquals("client1-b", region.get("b"));
        assertEquals("client1-c", region.get("c"));
        assertEquals("client2-d", region.get("d"));
        assertEquals("client1-e", region.get("e"));
        assertEquals("client1-f", region.get("f"));
        assertEquals("client2-g", region.get("g"));
        assertEquals("loaded1-h", region.get("h"));
      }
    });

    server.invoke(new SerializableRunnable() {
      @Override
      public void run() {
        Region region = getRootRegion(regionName);
        assertEquals("server-a", region.get("a"));
        assertEquals("client1-b", region.get("b"));
        assertEquals("client1-c", region.get("c"));
        assertEquals("client2-d", region.get("d"));
        assertEquals(null, region.get("e"));
        assertEquals(null, region.get("f"));

        // dsmith - This result seems somewhat suspect. client1 did a net load
        // which found a value in client2, but it never propagated that result
        // to the server. After talking with Darrel we decided to keep it this
        // way for now.
        assertEquals(null, region.get("g"));
        assertEquals("loaded1-h", region.get("h"));
      }
    });
  }
Test that we can have a peer, a server, and a bridge loader for the same region.

Expected order 1 localCache 2 peer 3 server 4 loader
geode-core/src/distributedTest/java/org/apache/geode/cache/ConnectionPoolAndLoaderDUnitTest.java