private void verifyListBindings(Context c, String name, Object obj1, Object obj2)
      throws NamingException {
    boolean datasourceFoundFlg = false;
    boolean o2FoundFlg = false;
    boolean datasourceO1FoundFlg = false;
    boolean datasourceNullFoundFlg = false;

    // List bindings for the specified context
    for (NamingEnumeration en = c.listBindings(name); en.hasMore();) {
      Binding b = (Binding) en.next();
      if (b.getName().equals("datasource")) {
        assertEquals(b.getObject(), dataSourceContext);
        datasourceFoundFlg = true;

        Context nextCon = (Context) b.getObject();
        for (NamingEnumeration en1 = nextCon.listBindings(""); en1.hasMore();) {
          Binding b1 = (Binding) en1.next();
          if (b1.getName().equals("sub41")) {
            assertEquals(b1.getObject(), obj1);
            datasourceO1FoundFlg = true;
          } else if (b1.getName().equals("sub43")) {
            // check for null object
            assertNull(b1.getObject());
            datasourceNullFoundFlg = true;
          }
        }
      } else if (b.getName().equals("sub42")) {
        assertEquals(b.getObject(), obj2);
        o2FoundFlg = true;
      }
    }
    if (!(datasourceFoundFlg && o2FoundFlg && datasourceO1FoundFlg && datasourceNullFoundFlg)) {
      fail();
    }
  }
Tests ability to list bindings for a context - specified by name through object reference.
geode-core/src/test/java/org/apache/geode/internal/jndi/ContextJUnitTest.java