@Test
  public void testValues() throws CacheException {
    String name = getUniqueName();
    LogService.getLogger().info("testValues region name is " + name);
    Region<Object, Object> region = createRegion(name);
    assertEquals(0, region.values().size());

    region.create("A", null);

    {
      Set<Object> values = new TreeSet<>(region.values());
      assertTrue(values.isEmpty());
      Iterator itr = values.iterator();
      assertFalse(itr.hasNext());
      try {
        itr.next();
        fail("Should have thrown NoSuchElementException");
      } catch (NoSuchElementException e) {
        // succeed
      }
    }

    region.put("A", "a");
    region.put("B", "b");
    region.put("C", "c");

    {
      Set<Object> values = new TreeSet<>(region.values());
      assertEquals(3, values.size());

      Iterator iter = values.iterator();
      assertTrue(iter.hasNext());
      assertEquals("a", iter.next());
      assertTrue(iter.hasNext());
      assertEquals("b", iter.next());
      assertTrue(iter.hasNext());
      assertEquals("c", iter.next());
      assertFalse(iter.hasNext());
    }

    // test invalid values
    region.invalidate("B");
    {
      Set<Object> values = new TreeSet<>(region.values());
      assertEquals(2, values.size());

      Iterator iter = values.iterator();
      assertTrue(iter.hasNext());
      assertEquals("a", iter.next());
      assertTrue(iter.hasNext());
      assertEquals("c", iter.next());
      assertFalse(iter.hasNext());
    }
  }
Tests the {@link Region#values} method without recursion
geode-dunit/src/main/java/org/apache/geode/cache30/RegionTestCase.java