@Test
    public void testInvalidSaslHandShakeRequest() {
        AbstractRequest request = new SaslHandshakeRequest.Builder(
                new SaslHandshakeRequestData().setMechanism("PLAIN")).build();
        ByteBuffer serializedBytes = request.serialize();
        // corrupt the length of the sasl mechanism string
        serializedBytes.putShort(0, Short.MAX_VALUE);

        String msg = assertThrows(RuntimeException.class, () -> AbstractRequest.
            parseRequest(request.apiKey(), request.version(), serializedBytes)).getMessage();
        assertEquals("Error reading byte array of 32767 byte(s): only 5 byte(s) available", msg);
    }
Check that all error codes in the response get included in {@link AbstractResponse#errorCounts()}.
clients/src/test/java/org/apache/kafka/common/requests/RequestResponseTest.java