@Test
public void testUncaughtExceptionHandlerWithOutOfMemoryError()
    throws InterruptedException {

  ExitUtil.disableSystemHalt();
  final YarnUncaughtExceptionHandler spyOomHandler = spy(exHandler);
  final OutOfMemoryError oomError = new OutOfMemoryError("out-of-memory-error");
  final Thread oomThread = new Thread(new Runnable() {
    @Override
    public void run() {
      throw oomError;
    }
  });
  oomThread.setUncaughtExceptionHandler(spyOomHandler);
  assertSame(spyOomHandler, oomThread.getUncaughtExceptionHandler());
  oomThread.start();
  oomThread.join();
  verify(spyOomHandler).uncaughtException(oomThread, oomError);
}