@Test
  public void test021Invalidate() throws Exception {
    int key = 0;
    PartitionedRegion pr = (PartitionedRegion) PartitionedRegionTestHelper
        .createPartitionedRegion("testInvalidate", String.valueOf(200), 0);

    // testing if the create is working fine.
    // It checks that it throws EntryExistsException for an already existing key
    Object getObj1 = null;
    Object getObj2 = null;
    for (int num = 0; num < 3; num++) {
      key++;
      try {
        pr.put(key, val + num);
      } catch (Exception e) {
        fail("testInvalidate(): put throws exception");
      }

      getObj1 = pr.get(key);

      if (!getObj1.equals(val + num)) {
        fail("testInvalidate(): Could not put a correct entry");
      }

      pr.invalidate(key);

      getObj2 = pr.get(key);
      if (getObj2 != null) {
        fail("testInvalidate(): Invalidate could not invalidate an entry");
      }

      String prefix = "1";
      String dummyKey = prefix + key;
      try {
        pr.invalidate(new Integer(dummyKey));
        fail("testInvalidate(): Invalidate doesnt not throw EntryNotFoundException");
      } catch (EntryNotFoundException enf) {
        if (logWriter.fineEnabled()) {
          logWriter.fine("testInvalidate(): Invalidate throws EntryNotFoundException");
        }
      }

      pr.destroy(key);

      try {
        pr.invalidate(new Integer(dummyKey));
        fail("testInvalidate(): Invalidate doesnt not throw EntryNotFoundException");
      } catch (EntryNotFoundException enf) {

        if (logWriter.fineEnabled()) {
          logWriter.fine("testInvalidate(): Invalidate throws EntryNotFoundException");
        }
      } catch (Exception e) {
        fail("testInvalidate(): Invalidate throws exception other than EntryNotFoundException");
      }
      assertEquals(num + 1,
          pr.getCache().getCachePerfStats().getInvalidates());

    }
    if (logWriter.fineEnabled()) {
      logWriter.fine(
          "PartitionedRegionSingleNodeOperationsJUnitTest - testInvalidate() Completed successfully ... ");
    }
  }
This method validates invalidate operations. It verfies that if entry exists, it is
invalidated. If entry does not exist, it throws EntryNotFoundException.
geode-core/src/integrationTest/java/org/apache/geode/internal/cache/PartitionedRegionSingleNodeOperationsJUnitTest.java