use of org.apache.qpid.server.protocol.v0_10.transport.SessionAttach 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)));
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionAttach in project qpid-broker-j by apache.
the class ServerConnectionDelegateTest method sessionAttachWhenNameIsUUID.
@Test
public void sessionAttachWhenNameIsUUID() {
final String name = UUID.randomUUID().toString();
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();
assertThat(session.getPeerSessionName(), CoreMatchers.is(equalTo(name)));
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionAttach in project qpid-broker-j by apache.
the class ServerConnectionDelegateTest method sessionAttachWhenNameIsNotUUID.
@Test
public void sessionAttachWhenNameIsNotUUID() {
final String name = "ABC";
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();
assertThat(session.getPeerSessionName(), CoreMatchers.is(equalTo(Base64.getEncoder().encodeToString(name.getBytes(UTF_8)))));
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionAttach in project qpid-broker-j by apache.
the class ServerConnectionDelegateTest method createSessionAttach.
private SessionAttach createSessionAttach(final String name) {
final SessionAttach attach = new SessionAttach();
attach.setName(name.getBytes(UTF_8));
return attach;
}
Aggregations