@Test
@Timeout(2_000)
public void testHandleApplicationException() {

  rule.connection.clearSendReceiveBuffers();
  Publisher<Payload> response = rule.socket.requestResponse(EmptyPayload.INSTANCE);
  Subscriber<Payload> responseSub = TestSubscriber.create();
  response.subscribe(responseSub);
  int streamId = rule.getStreamIdForRequestType(REQUEST_RESPONSE);
  rule.connection.addToReceivedBuffer(
      ErrorFrameCodec.encode(rule.alloc(), streamId, new ApplicationErrorException("error")));
  verify(responseSub).onError(any(ApplicationErrorException.class));
  Assertions.assertThat(rule.connection.getSent())
      // requestResponseFrame
      .hasSize(1)
      .allMatch(ReferenceCounted::release);
  rule.assertHasNoLeaks();
}