Search in sources :

Example 1 with SessionAttach

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)));
}
Also used : SessionAttach(org.apache.qpid.server.protocol.v0_10.transport.SessionAttach) Test(org.junit.Test)

Example 2 with SessionAttach

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)));
}
Also used : SessionAttach(org.apache.qpid.server.protocol.v0_10.transport.SessionAttach) Test(org.junit.Test)

Example 3 with SessionAttach

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)))));
}
Also used : SessionAttach(org.apache.qpid.server.protocol.v0_10.transport.SessionAttach) Test(org.junit.Test)

Example 4 with SessionAttach

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;
}
Also used : SessionAttach(org.apache.qpid.server.protocol.v0_10.transport.SessionAttach)

Aggregations

SessionAttach (org.apache.qpid.server.protocol.v0_10.transport.SessionAttach)4 Test (org.junit.Test)3