use of org.apache.qpid.server.protocol.v1_0.type.UnsignedShort in project qpid-broker-j by apache.
the class Interaction method sendPerformativeAndChainFuture.
private void sendPerformativeAndChainFuture(final FrameBody frameBody, final UnsignedShort channel) throws Exception {
final TransportFrame transportFrame;
try (QpidByteBuffer payload = frameBody instanceof Transfer ? ((Transfer) frameBody).getPayload() : null) {
final QpidByteBuffer duplicate;
if (payload == null) {
duplicate = null;
} else {
duplicate = payload.duplicate();
}
transportFrame = new TransportFrame(channel.shortValue(), frameBody, duplicate);
ListenableFuture<Void> listenableFuture = sendPerformativeAndChainFuture(transportFrame);
if (frameBody instanceof Transfer) {
listenableFuture.addListener(() -> ((Transfer) frameBody).dispose(), MoreExecutors.directExecutor());
}
if (duplicate != null) {
listenableFuture.addListener(() -> duplicate.dispose(), MoreExecutors.directExecutor());
}
}
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedShort in project qpid-broker-j by apache.
the class BeginTest method successfulBegin.
@Test
@SpecificationTest(section = "2.5.1", description = "Sessions are established by creating a session endpoint, assigning it to an unused channel number, " + "and sending a begin announcing the association of the session endpoint with the outgoing channel.")
public void successfulBegin() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final UnsignedShort channel = UnsignedShort.valueOf(37);
Interaction interaction = transport.newInteraction();
Begin responseBegin = interaction.negotiateOpen().sessionChannel(channel).begin().consumeResponse().getLatestResponse(Begin.class);
assertThat(responseBegin.getRemoteChannel(), equalTo(channel));
assertThat(responseBegin.getIncomingWindow(), is(instanceOf(UnsignedInteger.class)));
assertThat(responseBegin.getOutgoingWindow(), is(instanceOf(UnsignedInteger.class)));
assertThat(responseBegin.getNextOutgoingId(), is(instanceOf(UnsignedInteger.class)));
interaction.end().consumeResponse(End.class).close().consumeResponse(Close.class);
}
}
use of org.apache.qpid.server.protocol.v1_0.type.UnsignedShort in project qpid-broker-j by apache.
the class BeginTest method channelMax.
@Test
@SpecificationTest(section = "2.7.1", description = "A peer MUST not use channel numbers outside the range that its partner can handle." + "A peer that receives a channel number outside the supported range MUST close " + "the connection with the framing-error error-code..")
public void channelMax() throws Exception {
try (FrameTransport transport = new FrameTransport(getBrokerAdmin()).connect()) {
final Interaction interaction = transport.newInteraction();
final int ourChannelMax = 5;
final Open responseOpen = interaction.openChannelMax(UnsignedShort.valueOf(ourChannelMax)).negotiateOpen().getLatestResponse(Open.class);
final UnsignedShort remoteChannelMax = responseOpen.getChannelMax();
assumeThat(remoteChannelMax, is(notNullValue()));
assumeThat(remoteChannelMax.intValue(), is(lessThan(UnsignedShort.MAX_VALUE.intValue())));
final int illegalSessionChannel = remoteChannelMax.intValue() + 1;
final Close responseClose = interaction.sessionChannel(UnsignedShort.valueOf(illegalSessionChannel)).begin().consumeResponse().getLatestResponse(Close.class);
assertThat(responseClose.getError(), is(notNullValue()));
assertThat(responseClose.getError().getCondition(), equalTo(ConnectionError.FRAMING_ERROR));
}
}
Aggregations