### Question:
PlainSaslServer implements SaslServer { @Override public byte[] evaluateResponse(byte[] response) throws SaslException { int authzidNullPosition = Bytes.indexOf(response, (byte) 0); if (authzidNullPosition < 0) { throw new SaslException("Invalid SASL/PLAIN response due to authzid null separator not found"); } int authcidNullPosition = Bytes .indexOf(Arrays.copyOfRange(response, authzidNullPosition + 1, response.length), (byte) 0); if (authcidNullPosition < 0) { throw new SaslException("Invalid SASL/PLAIN response due to authcid null separator not found"); } String userName = new String(response, authzidNullPosition + 1, authcidNullPosition, StandardCharsets.UTF_8); int counter = authzidNullPosition + authcidNullPosition + 1; int passwordLen = response.length - counter - 1; password = new char[passwordLen]; for (int i = 0; i < passwordLen; i++) { password[i] = (char) response[++counter]; } try { AuthResult authResult = authenticator.authenticate(userName, password); authenticationId = authResult.getUserId(); isComplete = authResult.isAuthenticated(); return new byte[0]; } catch (AuthException e) { throw new SaslException("Error while authenticating user with authenticator", e); } finally { clearCredentials(); } } PlainSaslServer(Authenticator authenticator); @Override String getMechanismName(); @Override byte[] evaluateResponse(byte[] response); @Override boolean isComplete(); @Override String getAuthorizationID(); @Override byte[] unwrap(byte[] incoming, int offset, int len); @Override byte[] wrap(byte[] outgoing, int offset, int len); @Override Object getNegotiatedProperty(String propName); @Override void dispose();  }### Answer:
@Test(expectedExceptions = { SaslException.class }, description = "Test evaluate empty response", expectedExceptionsMessageRegExp = ".*Invalid SASL/PLAIN response due to authzid null separator not found.*") public void testEvaluateEmptyResponse() throws Exception { plainSaslServer.evaluateResponse(new byte[0]); }
@Test(expectedExceptions = SaslException.class, description = "Test evaluate response without authorization separator", expectedExceptionsMessageRegExp = ".*Invalid SASL/PLAIN response due to authzid null separator not found.*") public void testEvaluateResponseWithoutAuthorizationSeparator() throws Exception { plainSaslServer.evaluateResponse(new byte[] { (byte) 'a', (byte) 'u', (byte) 't', (byte) 'h' }); }
@Test(expectedExceptions = SaslException.class, description = "Test evaluate response without username separator", expectedExceptionsMessageRegExp = ".*Invalid SASL/PLAIN response due to authcid null separator not found.*") public void testEvaluateResponseWithoutUsernameSeparator() throws Exception { plainSaslServer .evaluateResponse(new byte[] { (byte) 'a', (byte) 0, (byte) 'u', (byte) 's', (byte) 'e', (byte) 'r' }); }