private void assertRootCause(Throwable throwable, Class<?> expected) {
    boolean passed = false;
    Throwable cause = throwable.getCause();
    while (cause != null) {
      if (cause.getClass().equals(expected)) {
        passed = true;
        break;
      }
      cause = cause.getCause();
    }
    if (!passed) {
      throw new AssertionError("Throwable does not contain expected root cause " + expected,
          throwable);
    }
  }
Test behavior of region when running out of off-heap memory.
geode-core/src/distributedTest/java/org/apache/geode/internal/offheap/OutOfOffHeapMemoryDUnitTest.java