@Test
  public void testRandomGrowRemoveRelease() {
    ObjIdMap map = new ObjIdMap();
    Random random = new Random(System.currentTimeMillis());
    List saver = new ArrayList();
    BitSet bits = new BitSet();
    int maxSize = 10000;
    boolean growing = true;
    int numAdds = 0;
    int numRemoves = 0;
    int numReleases = 0;
    int numChecks = 0;

    while (growing || saver.size() > 0) {
      int op = random.nextInt(8);
      // System.out.println("saver size: " + saver.size() + ", map size: " + map.size());
      switch (op) {
        case 0: // Add new value - more likely to occur than removes
        case 1:
        case 2:
          if (!growing) {
            break;
          }
          int key = Math.abs(random.nextInt(10 * maxSize));
          if (bits.get(key)) {
            // We don't want the newValue in the saver List twice
            // because it is only in the map once.
            continue;
          }
          Integer newValue = key;
          numAdds++;
          map.put(key, new WeakReference(newValue));
          saver.add(newValue);
          bits.set(key);
          if (saver.size() >= maxSize) {
            growing = false;
          }
          break;
        case 3: // Explicitly remove random entry
          if (saver.size() == 0) {
            break;
          }
          numRemoves++;
          key = random.nextInt(saver.size());
          Integer value = (Integer) saver.remove(key);
          bits.clear(value);
          assertNotNull(map.remove(value));
          break;
        case 4: // Release reference to random entry
          if (saver.size() == 0) {
            break;
          }
          numReleases++;
          key = random.nextInt(saver.size());
          value = (Integer) saver.remove(key);
          bits.clear(value);
          break;
        case 5: // Validate random entry
        case 6:
        case 7:
          if (saver.size() == 0) {
            break;
          }
          numChecks++;
          Integer valueToCheck = (Integer) saver.get(random.nextInt(saver.size()));
          WeakReference ref = (WeakReference) map.get(valueToCheck);
          assertTrue(ref != null);
          assertEquals(valueToCheck, ref.get());
          break;
        default:
          fail("Bad op: " + op);
      }
    }
    System.out.println("map size: " + map.size() + ", numAdds: " + numAdds + ", numRemoves: "
        + numRemoves + ", numReleases: " + numReleases + ", numChecks: " + numChecks);
  }
This class tests the functionality of the {@link ObjIdMap} class.
geode-core/src/test/java/org/apache/geode/internal/ObjIdMapJUnitTest.java