use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.
the class SessionTest method detach.
@Test
@SpecificationTest(section = "9.session.detach", description = "Detaches the current transport from the named session.")
public void detach() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
final int channelId = 1;
SessionDetached sessionDetached = interaction.openAnonymousConnection().channelId(channelId).session().attachName(sessionName).attach().consumeResponse(SessionAttached.class).session().detachName(sessionName).detach().consumeResponse().getLatestResponse(SessionDetached.class);
assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.
the class SessionTest method detachUnknownSession.
@Test
@SpecificationTest(section = "9.session", description = "The transport MUST be attached in order to use any control other than" + " \"attach\", \"attached\", \"detach\", or \"detached\"." + " A peer receiving any other control on a detached transport MUST discard it and send a" + " session.detached with the \"not-attached\" reason code.")
public void detachUnknownSession() throws Exception {
try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction = transport.newInteraction();
byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
final int channelId = 1;
SessionDetached sessionDetached = interaction.openAnonymousConnection().channelId(channelId).session().detachName(sessionName).detach().consumeResponse().getLatestResponse(SessionDetached.class);
assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId));
}
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.
the class ServerConnection method invokeSessionDetached.
private void invokeSessionDetached(int channel, SessionDetachCode sessionDetachCode) {
SessionDetached sessionDetached = new SessionDetached();
sessionDetached.setChannel(channel);
sessionDetached.setCode(sessionDetachCode);
invoke(sessionDetached);
}
use of org.apache.qpid.server.protocol.v0_10.transport.SessionDetached in project qpid-broker-j by apache.
the class SessionTest method attachSameSessionTwiceDisallowed.
@Test
@SpecificationTest(section = "9.session", description = "A session MUST NOT be attached to more than one transport at a time.")
public void attachSameSessionTwiceDisallowed() throws Exception {
try (FrameTransport transport1 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction1 = transport1.newInteraction();
byte[] sessionName = "test".getBytes(StandardCharsets.UTF_8);
final int channelId1 = 1;
SessionAttached sessionAttached = interaction1.openAnonymousConnection().channelId(channelId1).session().attachName(sessionName).attach().consumeResponse().getLatestResponse(SessionAttached.class);
assertThat(sessionAttached.getName(), IsEqual.equalTo(sessionName));
assertThat(sessionAttached.getChannel(), IsEqual.equalTo(channelId1));
try (FrameTransport transport2 = new FrameTransport(_brokerAddress).connect()) {
final Interaction interaction2 = transport2.newInteraction();
final int channelId2 = 2;
SessionDetached sessionDetached = interaction2.openAnonymousConnection().channelId(channelId2).session().attachName(sessionName).attach().consumeResponse().getLatestResponse(SessionDetached.class);
assertThat(sessionDetached.getName(), IsEqual.equalTo(sessionName));
assertThat(sessionDetached.getCode(), IsEqual.equalTo(SessionDetachCode.SESSION_BUSY));
assertThat(sessionDetached.getChannel(), IsEqual.equalTo(channelId2));
}
}
}
Aggregations