@Test
  public void testKeysIteratorOnPR() {
    Host host = Host.getHost(0);
    VM accessor = host.getVM(0);
    VM datastore = host.getVM(1);
    final String regionName = getUniqueName();

    accessor.invoke(new SerializableCallable() {
      @Override
      public Object call() throws Exception {
        getGemfireCache().createRegionFactory(RegionShortcut.PARTITION_PROXY).create(regionName);
        return null;
      }
    });
    datastore.invoke(new SerializableCallable() {
      @Override
      public Object call() throws Exception {
        Region r =
            getGemfireCache().createRegionFactory(RegionShortcut.PARTITION).create(regionName);
        r.put("key", "value");
        r.put("key2", "value2");
        r.put("key3", "value3");
        PartitionedRegion pr = (PartitionedRegion) r;
        BucketRegion br = pr.getBucketRegion("key");
        assertNotNull(br);
        // simulate a removed key
        br.getRegionMap().getEntry("key").setValue(pr, Token.REMOVED_PHASE1);
        return null;
      }
    });
    accessor.invoke(new SerializableCallable() {
      @Override
      public Object call() throws Exception {
        Region r = getGemfireCache().getRegion(regionName);
        Iterator it = r.keySet().iterator();
        int numKeys = 0;
        while (it.hasNext()) {
          it.next();
          numKeys++;
        }
        assertEquals(2, numKeys);
        return null;
      }
    });
  }
Test that keys iterator do not returned keys with removed token as its values
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/IteratorDUnitTest.java