Search in sources :

Example 1 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class Session_1_0Test method createSession_1_0.

private Session_1_0 createSession_1_0(final AMQPConnection_1_0 connection, int channelId) {
    Begin begin = mock(Begin.class);
    when(begin.getNextOutgoingId()).thenReturn(new UnsignedInteger(channelId));
    return new Session_1_0(connection, begin, channelId, channelId, 2048);
}
Also used : Begin(org.apache.qpid.server.protocol.v1_0.type.transport.Begin) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 2 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class Session_1_0Test method sendDetach.

private void sendDetach(final Session_1_0 session, final UnsignedInteger handle, final boolean closed) {
    final Detach detach = new Detach();
    detach.setHandle(handle);
    detach.setClosed(closed);
    session.receiveDetach(detach);
}
Also used : Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach)

Example 3 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_8 method convertMetaData.

private MessageMetaData convertMetaData(final Message_1_0 serverMsg, final String bodyMimeType, final int size, final NamedAddressSpace addressSpace) {
    final MessageMetaData_1_0.MessageHeader_1_0 header = serverMsg.getMessageHeader();
    final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
    props.setAppId(serverMsg.getMessageHeader().getAppId());
    props.setContentType(bodyMimeType);
    props.setEncoding(convertToShortStringForProperty("content-encoding", serverMsg.getMessageHeader().getEncoding()));
    props.setCorrelationId(getCorrelationIdAsShortString(serverMsg));
    props.setDeliveryMode(serverMsg.isPersistent() ? BasicContentHeaderProperties.PERSISTENT : BasicContentHeaderProperties.NON_PERSISTENT);
    final Date absoluteExpiryTime = getAbsoluteExpiryTime(serverMsg);
    if (absoluteExpiryTime != null) {
        props.setExpiration(absoluteExpiryTime.getTime());
    } else {
        Long ttl = getTtl(serverMsg);
        if (ttl != null) {
            props.setExpiration(ttl + serverMsg.getArrivalTime());
        }
    }
    props.setMessageId(getMessageIdAsShortString(serverMsg));
    props.setPriority(serverMsg.getMessageHeader().getPriority());
    props.setReplyTo(getReplyTo(serverMsg, addressSpace));
    Date timestamp = getCreationTime(serverMsg);
    if (timestamp != null) {
        props.setTimestamp(timestamp.getTime());
    } else {
        props.setTimestamp(serverMsg.getArrivalTime());
    }
    props.setUserId(getUserIdAsShortString(serverMsg));
    Map<String, Object> headerProps = new LinkedHashMap<>();
    if (header.getSubject() != null) {
        headerProps.put("qpid.subject", header.getSubject());
        props.setType(convertToShortStringForProperty("subject", header.getSubject()));
    }
    String groupId = getGroupId(serverMsg);
    if (groupId != null) {
        headerProps.put("JMSXGroupID", groupId);
    }
    UnsignedInteger groupSequence = getGroupSequence(serverMsg);
    if (groupSequence != null) {
        headerProps.put("JMSXGroupSeq", groupSequence.intValue());
    }
    for (String headerName : serverMsg.getMessageHeader().getHeaderNames()) {
        headerProps.put(headerName, convertValue(serverMsg.getMessageHeader().getHeader(headerName)));
    }
    final FieldTable headers;
    try {
        headers = FieldTable.convertToFieldTable(headerProps);
    } catch (IllegalArgumentException e) {
        throw new MessageConversionException("Could not convert message from 1.0 to 0-8 because conversion of 'application-properties' failed.", e);
    }
    props.setHeaders(headers);
    final ContentHeaderBody chb = new ContentHeaderBody(props);
    chb.setBodySize(size);
    MessagePublishInfo publishInfo = createMessagePublishInfo(header, addressSpace);
    return new MessageMetaData(publishInfo, chb, serverMsg.getArrivalTime());
}
Also used : MessagePublishInfo(org.apache.qpid.server.protocol.v0_8.transport.MessagePublishInfo) MessageMetaData(org.apache.qpid.server.protocol.v0_8.MessageMetaData) MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) ContentHeaderBody(org.apache.qpid.server.protocol.v0_8.transport.ContentHeaderBody) FieldTable(org.apache.qpid.server.protocol.v0_8.FieldTable) MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)

Example 4 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class ResumeDeliveriesTest method rejectNewDeliveryWhilstUnsettledIncomplete.

@Ignore("QPID-7845")
@Test
@SpecificationTest(section = "2.7.3", description = "If set to true [incomplete-unsettled] indicates that the unsettled map provided is not complete. " + "When the map is incomplete the recipient of the map cannot take the absence of a delivery tag from " + "the map as evidence of settlement. On receipt of an incomplete unsettled map a sending endpoint MUST " + "NOT send any new deliveries (i.e. deliveries where resume is not set to true) to its partner (and " + "a receiving endpoint which sent an incomplete unsettled map MUST detach with an error on " + "receiving a transfer which does not have the resume flag set to true).")
public void rejectNewDeliveryWhilstUnsettledIncomplete() throws Exception {
    final String destination = BrokerAdmin.TEST_QUEUE_NAME;
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = transport.newInteraction();
        interaction.negotiateProtocol().consumeResponse();
        // 0. Open connection with small max-frame-size
        final Open open = interaction.openMaxFrameSize(UnsignedInteger.valueOf(MIN_MAX_FRAME_SIZE)).open().consumeResponse().getLatestResponse(Open.class);
        interaction.begin().consumeResponse(Begin.class);
        // 1. attach with ReceiverSettleMode.SECOND
        final UnsignedInteger linkHandle1 = UnsignedInteger.ZERO;
        interaction.attachHandle(linkHandle1).attachRole(Role.SENDER).attachRcvSettleMode(ReceiverSettleMode.SECOND).attachTargetAddress(destination).attach().consumeResponse(Attach.class).consumeResponse(Flow.class);
        // 2. send enough unsettled deliverys to cause incomplete-unsettled to be true
        // assume each delivery requires at least 1 byte, therefore max-frame-size deliveries should be enough
        interaction.transferHandle(linkHandle1).transferPayloadData(TEST_MESSAGE_CONTENT);
        Map<Binary, DeliveryState> localUnsettled = new HashMap<>(open.getMaxFrameSize().intValue());
        for (int i = 0; i < open.getMaxFrameSize().intValue(); ++i) {
            final Binary deliveryTag = new Binary(String.valueOf(i).getBytes(StandardCharsets.UTF_8));
            final Disposition responseDisposition = interaction.transferDeliveryId(UnsignedInteger.valueOf(i)).transferDeliveryTag(deliveryTag).transfer().consumeResponse(Disposition.class).getLatestResponse(Disposition.class);
            assertThat(responseDisposition.getRole(), is(Role.RECEIVER));
            assertThat(responseDisposition.getSettled(), is(Boolean.FALSE));
            localUnsettled.put(deliveryTag, null);
        }
        // 3. detach the link
        interaction.detach().consumeResponse(Detach.class);
        // 4. resume the link
        final UnsignedInteger linkHandle2 = UnsignedInteger.ONE;
        final Binary sampleLocalUnsettled = localUnsettled.keySet().iterator().next();
        Map<Binary, DeliveryState> unsettled = Collections.singletonMap(sampleLocalUnsettled, localUnsettled.get(sampleLocalUnsettled));
        final Response<?> latestResponse = interaction.attachHandle(linkHandle2).attachUnsettled(unsettled).attachIncompleteUnsettled(true).attach().consumeResponse(End.class, Attach.class).getLatestResponse();
        assumeThat(latestResponse.getBody(), is(instanceOf(Attach.class)));
        // 5. ensure attach has incomplete-unsettled
        final Attach responseAttach = (Attach) latestResponse.getBody();
        assertThat(responseAttach.getIncompleteUnsettled(), is(equalTo(true)));
        // 6. send new transfer
        final Binary newDeliveryTag = new Binary("newTransfer".getBytes(StandardCharsets.UTF_8));
        final Detach detachWithError = interaction.transferHandle(linkHandle2).transferDeliveryId(UnsignedInteger.ONE).transferDeliveryTag(newDeliveryTag).transfer().consumeResponse().getLatestResponse(Detach.class);
        assertThat(detachWithError.getError(), is(notNullValue()));
        final Error detachError = detachWithError.getError();
        assertThat(detachError.getCondition(), is(equalTo(AmqpError.ILLEGAL_STATE)));
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) HashMap(java.util.HashMap) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) Open(org.apache.qpid.server.protocol.v1_0.type.transport.Open) DeliveryState(org.apache.qpid.server.protocol.v1_0.type.DeliveryState) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) End(org.apache.qpid.server.protocol.v1_0.type.transport.End) Binary(org.apache.qpid.server.protocol.v1_0.type.Binary) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) Detach(org.apache.qpid.server.protocol.v1_0.type.transport.Detach) Ignore(org.junit.Ignore) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Example 5 with UnsignedInteger

use of org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger in project qpid-broker-j by apache.

the class AnonymousTerminusTest method transferUnsettledInTransactionToUnknownDestinationWhenRejectedOutcomeSupportedBySource.

@Test
public void transferUnsettledInTransactionToUnknownDestinationWhenRejectedOutcomeSupportedBySource() throws Exception {
    try (FrameTransport transport = new FrameTransport(_brokerAddress).connect()) {
        final Interaction interaction = openInteractionWithAnonymousRelayCapability(transport);
        final UnsignedInteger linkHandle = UnsignedInteger.ONE;
        final InteractionTransactionalState txnState = interaction.createTransactionalState(UnsignedInteger.ZERO);
        interaction.begin().consumeResponse(Begin.class).txnAttachCoordinatorLink(txnState).txnDeclare(txnState).attachRole(Role.SENDER).attachSourceOutcomes(Accepted.ACCEPTED_SYMBOL, Rejected.REJECTED_SYMBOL).attachHandle(linkHandle).attach().consumeResponse(Attach.class).consumeResponse(Flow.class).transferHandle(linkHandle).transferPayload(generateMessagePayloadToDestination("Unknown")).transferDeliveryTag(_deliveryTag).transferTransactionalState(txnState.getCurrentTransactionId()).transferSettled(Boolean.FALSE).transfer();
        Disposition disposition = interaction.consumeResponse().getLatestResponse(Disposition.class);
        assertThat(disposition.getSettled(), is(true));
        DeliveryState dispositionState = disposition.getState();
        assertThat(dispositionState, is(instanceOf(TransactionalState.class)));
        final TransactionalState receivedTxnState = (TransactionalState) dispositionState;
        assertThat(receivedTxnState.getOutcome(), is(instanceOf(Rejected.class)));
        final Error rejectedError = ((Rejected) receivedTxnState.getOutcome()).getError();
        assertThat(rejectedError.getCondition(), is(equalTo(AmqpError.NOT_FOUND)));
        assertThat(rejectedError.getInfo(), is(notNullValue()));
        assertThat(rejectedError.getInfo().get(DELIVERY_TAG), is(equalTo(_deliveryTag)));
        interaction.txnDischarge(txnState, false);
    }
}
Also used : FrameTransport(org.apache.qpid.tests.protocol.v1_0.FrameTransport) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) DeliveryState(org.apache.qpid.server.protocol.v1_0.type.DeliveryState) Interaction(org.apache.qpid.tests.protocol.v1_0.Interaction) Attach(org.apache.qpid.server.protocol.v1_0.type.transport.Attach) Disposition(org.apache.qpid.server.protocol.v1_0.type.transport.Disposition) Error(org.apache.qpid.server.protocol.v1_0.type.transport.Error) AmqpError(org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError) TransactionError(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError) Rejected(org.apache.qpid.server.protocol.v1_0.type.messaging.Rejected) UnsignedInteger(org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger) InteractionTransactionalState(org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState) TransactionalState(org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionalState) Test(org.junit.Test) SpecificationTest(org.apache.qpid.tests.protocol.SpecificationTest)

Aggregations

UnsignedInteger (org.apache.qpid.server.protocol.v1_0.type.UnsignedInteger)57 FrameTransport (org.apache.qpid.tests.protocol.v1_0.FrameTransport)35 Test (org.junit.Test)35 Interaction (org.apache.qpid.tests.protocol.v1_0.Interaction)33 SpecificationTest (org.apache.qpid.tests.protocol.SpecificationTest)29 Attach (org.apache.qpid.server.protocol.v1_0.type.transport.Attach)25 Disposition (org.apache.qpid.server.protocol.v1_0.type.transport.Disposition)20 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)18 Flow (org.apache.qpid.server.protocol.v1_0.type.transport.Flow)17 Open (org.apache.qpid.server.protocol.v1_0.type.transport.Open)14 InteractionTransactionalState (org.apache.qpid.tests.protocol.v1_0.InteractionTransactionalState)13 Error (org.apache.qpid.server.protocol.v1_0.type.transport.Error)12 AmqpError (org.apache.qpid.server.protocol.v1_0.type.transport.AmqpError)11 Begin (org.apache.qpid.server.protocol.v1_0.type.transport.Begin)11 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 DeliveryState (org.apache.qpid.server.protocol.v1_0.type.DeliveryState)8 TransactionError (org.apache.qpid.server.protocol.v1_0.type.transaction.TransactionError)7 InetSocketAddress (java.net.InetSocketAddress)6 Detach (org.apache.qpid.server.protocol.v1_0.type.transport.Detach)6 Transfer (org.apache.qpid.server.protocol.v1_0.type.transport.Transfer)6