use of org.apache.qpid.server.protocol.v0_10.ServerConnectionDelegate.BASE64_LIMIT in project qpid-broker-j by apache.
the class ServerConnectionDelegateTest method sessionAttachWhenNameExceedsSizeLimit.
@Test
public void sessionAttachWhenNameExceedsSizeLimit() throws Exception {
final String name = Stream.generate(() -> String.valueOf('a')).limit(BASE64_LIMIT + 1).collect(Collectors.joining());
;
final SessionAttach attach = createSessionAttach(name);
_delegate.sessionAttach(_serverConnection, attach);
final ArgumentCaptor<ServerSession> sessionCaptor = ArgumentCaptor.forClass(ServerSession.class);
verify(_serverConnection).registerSession(sessionCaptor.capture());
final ServerSession serverSession = sessionCaptor.getValue();
final Session session = serverSession.getModelObject();
final String digest = Base64.getEncoder().encodeToString(MessageDigest.getInstance(MESSAGE_DIGEST_SHA1).digest(name.getBytes(UTF_8)));
assertThat(session.getPeerSessionName(), CoreMatchers.is(equalTo(digest)));
}
Aggregations