@Test
  public void testSingleVMInvalidate() {
    Host host = Host.getHost(0);
    VM vm = host.getVM(0);
    final String rName = getUniqueName();
    vm.invoke(new SerializableCallable() {
      @Override
      public Object call() throws Exception {
        createRegion(rName, false, 0, null);
        Region r = getCache().getRegion(rName);
        InvalidatePRListener l = new InvalidatePRListener();
        r.getAttributesMutator().addCacheListener(l);
        for (int i = 0; i <= 113; i++) {
          r.put(i, "value" + i);
        }
        PartitionedRegion pr = (PartitionedRegion) r;
        assertTrue(pr.getDataStore().getAllLocalBuckets().size() == 113);
        for (Object v : pr.values()) {
          assertNotNull(v);
        }
        r.invalidateRegion();
        assertTrue(l.afterRegionInvalidateCalled);
        l.afterRegionInvalidateCalled = false;
        for (int i = 0; i <= 113; i++) {
          r.put(i, "value" + i);
        }
        Object callbackArg = "CallBACK";
        l.callbackArg = callbackArg;
        r.invalidateRegion(callbackArg);
        assertTrue(l.afterRegionInvalidateCalled);
        l.afterRegionInvalidateCalled = false;
        return null;
      }
    });
  }
This tests invalidateRegion functionality on partitioned regions
geode-core/src/distributedTest/java/org/apache/geode/internal/cache/PartitionedRegionInvalidateDUnitTest.java