Search in sources :

Example 1 with UnsignedShort

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());
        }
    }
}
Also used : TransportFrame(org.apache.qpid.server.protocol.v1_0.framing.TransportFrame) Transfer(org.apache.qpid.server.protocol.v1_0.type.transport.Transfer) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 2 with UnsignedShort

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);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) UnsignedShort(org.apache.qpid.server.protocol.v1_0.type.UnsignedShort) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 3 with UnsignedShort

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));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Close(org.apache.qpid.server.protocol.v1_0.type.transport.Close) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) UnsignedShort(org.apache.qpid.server.protocol.v1_0.type.UnsignedShort) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

UnsignedShort (org.apache.qpid.server.protocol.v1_0.type.UnsignedShort)2 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)2 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)2 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)2 Test (org.junit.Test)2 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)1 TransportFrame (org.apache.qpid.server.protocol.v1_0.framing.TransportFrame)1 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)1 Close (org.apache.qpid.server.protocol.v1_0.type.transport.Close)1 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)1 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)1