@Test
  public void testReplicationAndTransactions() throws Exception {
    final String r1 = getUniqueName() + "-1";
    final String r2 = getUniqueName() + "-2";
    final String r3 = getUniqueName() + "-3";

    VM feeder = Host.getHost(0).getVM(3);
    VM repl = Host.getHost(0).getVM(2);

    final int maxEntries = 1;
    final int numEntries = 10000;
    final int txBatchSize = 10;
    assertTrue(numEntries > txBatchSize); // need at least one batch

    CacheSerializableRunnable createRegion =
        new CacheSerializableRunnable("Create Replicate Region") {
          @Override
          public void run2() throws CacheException {
            AttributesFactory factory = new AttributesFactory();
            factory.setOffHeap(isOffHeapEnabled());
            factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maxEntries,
                EvictionAction.OVERFLOW_TO_DISK));
            factory.setDataPolicy(DataPolicy.REPLICATE);

            File[] diskDirs = new File[1];
            diskDirs[0] = new File("overflowDir/" + OSProcess.getId());
            diskDirs[0].mkdirs();
            factory.setDiskStoreName(getCache().createDiskStoreFactory().setDiskDirs(diskDirs)
                .create("LRUEvictionControllerDUnitTest").getName());
            factory.setDiskSynchronous(true);

            factory.setScope(Scope.DISTRIBUTED_ACK);
            RegionAttributes a = factory.create();
            createRegion(r1, a);
            createRegion(r2, a);
            createRegion(r3, a);
          }
        };
    feeder.invoke(createRegion);
    repl.invoke(createRegion);

    feeder.invoke(new CacheSerializableRunnable(
        "put " + numEntries + " entries and assert " + maxEntries + " max entries") {
      @Override
      public void run2() throws CacheException {
        Cache c = getCache();
        CacheTransactionManager txm = c.getCacheTransactionManager();

        Region reg1 = getRootRegion().getSubregion(r1);
        assertNotNull(reg1);

        Region reg2 = getRootRegion().getSubregion(r2);
        assertNotNull(reg2);

        Region reg3 = getRootRegion().getSubregion(r3);
        assertNotNull(reg3);

        boolean startTx = false;
        final Region[] r = {reg1, reg2, reg3};
        for (int i = 0; i < numEntries; i++) {
          if (i % txBatchSize == 0) {
            txm.begin();
            startTx = true;
          }
          reg1.create("r1-key-" + i, "r1-value-" + i);
          reg2.create("r2-key-" + i, "r2-value-" + i);
          reg3.create("r3-key-" + i, "r3-value-" + i);

          if (i % txBatchSize == (txBatchSize - 1)) {
            txm.commit();
            try { // allow stats to get a sample in
              Thread.sleep(20);
            } catch (InterruptedException ie) {
              fail("interrupted");
            }
            startTx = false;
          }
        }
        if (startTx) {
          txm.commit();
        }

        for (final Region region : r) {
          assertEquals(numEntries, region.size());
          {
            LocalRegion lr = (LocalRegion) region;
            assertEquals(maxEntries, lr.getEvictionController().getCounters().getLimit());
            assertEquals(maxEntries, lr.getEvictionController().getCounters().getCounter());
          }
        }
      }
    });

    repl.invoke(new CacheSerializableRunnable("Replicate asserts " + maxEntries + " max entries") {
      @Override
      public void run2() throws CacheException {
        getCache();
        Region reg1 = getRootRegion().getSubregion(r1);
        Region reg2 = getRootRegion().getSubregion(r2);
        Region reg3 = getRootRegion().getSubregion(r3);

        final Region[] r = {reg1, reg2, reg3};
        for (final Region region : r) {
          assertNotNull(region);
          assertEquals(numEntries, region.size());
          {
            LocalRegion lr = (LocalRegion) region;
            assertEquals(maxEntries, lr.getEvictionController().getCounters().getLimit());
            assertEquals(maxEntries, lr.getEvictionController().getCounters().getCounter());
          }
        }

      }
    });
  }
Create two regions, one a "feed" that performs transactions which are replicated to a region
with an Entry LRU set to one Asserts that the LRU rules are observed
geode-core/src/distributedTest/java/org/apache/geode/cache30/LRUEvictionControllerDUnitTest.java